How to find merged cells in Excel

How to find merged cells in Excel



Merging statistics from a couple of Excel worksheet cells may be quite essential in certain conditions. For example, you can have imported records from a database like MS Access, SQL or mySql into Excel and you currently have the first name, center name and final name of the employees in three distinct cells under their respective headers or labels. You desire to convey all the records in the 3 cells into one single cellular with a label like 'name'. Of direction you may use the concatenate characteristic. Or you may use the 'merge and middle' feature of Excel. But this selection purpose facts loss and the former allows only operating on one statistics at a time.

How to find merged cells in Excel

Using a macro or VBA code you may effortlessly merge the records from thousands of cells inside some seconds. You use a looping manner to your macro. Once the records has been merged you could center or format it in keeping with your requirements quickly and without difficulty by means of adding a few extra strains of code.


Given under is the macro code to merge records in Excel cells:


Sub MergeAndCenter()


Dim myText As String, mySpace As String


mySpace = " "


Cells(1, 1) = "Name"


Cells(1, 2) = ""


x = 2


Do While Cells(x, 1) <> ""


Cells(x, 1) = Cells(x, 1) & mySpace & Cells(x, 2)


Cells(x, 2) = ""


x = x + 1


Loop


End Sub


Remember when you run the macro you can not undo it.


But help is to hand, Using the 'text to columns' feature underneath the records tab within the 'facts equipment' institution you can revert again in your authentic statistics. Of course, the records inside the headers will need to be entered manually. For instance, you can need to enter 'First Name', 'iddle Name' and 'Last Name' in the first row so that you know what sort of facts is to be predicted in every column.


Now let's consider you run the above macro and automatically merge the records to your worksheet. You can also find that the records is left centered. You can without difficulty center the information. Just report a macro by using doing the all of the movements that you could have achieved whilst formatting information in Excel. Now have a take a look at the code and you may without difficulty understand why you just need these strains of code to remedy the trouble of center alignment:


'Code to center the text


Columns("A:A").Select


With Selection


.HorizontalAlignment = xlCenter


.VerticalAlignment = xlBottom


End With


Similarly if you desired to 'autofit' the facts in the cells you'll once more record a easy macro to get the subsequent line of code:


Columns("A:A").EntireColumn.AutoFit


Using VBA or a macro for such responsibilities can automate the complete technique and you saw that it's on no account difficult to research or enforce!

Report Page