Help req in merging cells

  • Thread starter deepika :excel help
  • Start date
D

deepika :excel help

i have written the following code to merge cells inside a macro.



Name = "Prathap"
S = 1
e = 1
For i = S To e
If (Name <> Sheets("FTP").Cells(i, 2).Value) Then
Range(B,start:B,end)
Name = Sheets("FTP").Cells(i, 2).Merge
S = i + 1
e = i

Here what i wanted to convey is taht i want to merge all the cells of
columns A ,B and C for a particular name i col B. teh rest of teh columns
need not be merged . and then the following name is also to bemerged the same
way.
The entries are dynamic . Im not able to proceed beyond this as im new to
coding
 
G

Gary''s Student

Perhaps this code can help you:

Sub mergge()
For I = 1 To 10
If Cells(I, 2).Value = "Prathap" Then
Range("A" & I & ":C" & I).merge
End If
Next
End Sub
 
D

deepika :excel help

this code is actually deleing all teh entries below that row... Actually i
want to only merge one column .. the other columns should not be merged..

I have written the following code which doent work

i=3
Name = "Prathap"
st = i
en = i
If (Name <> Sheets("FTP").Cells(i, 2).Value) Then
st = i + 1
en = i
Else
Sheets("FTP").Cells(i, 2).merge
name = Sheets("FTP").Cells(i+1, 2).Value

End If

also teh structure has to be like :
colA col B Col C
Row1 1 Prathap paint
row2 draw
row3 2 Rohan test

before the above , the structure is now like
colA col B Col C
Row1 1 Prathap paint
row2 1 Prathap draw
row3 2 Rohan test

So howmany ever Prathap i see i should merge it to a single cell leaving col
C unmerged and for teh rest of the rows... also this shud be teh case..
Can u help pls
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top