• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code for Merging

siddhuprince86

New Member
Hello Guys,

I am new to VBA programming , I have recently created a User form , wrote down the code to transfer to the Excel format ,

In this course of action, some Columns like material are having values for 4 individual Rows , rest of the columns only 4 Row is having the values ,
I wanted to merge the before cells to make the sheet legible,

I have used

Code:
Sub vba_merge()

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Supplier master")

With sh.Range("B" & n + 4)
    .Merge
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlCenter

End With

End Sub
I am enable made it in code format it is not working
 

Attachments

Last edited by a moderator:

siddhuprince86

New Member
XML:
Sub vba_merge()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Supplier master")

With sh.Range("B" & n + 4)

    .Merge

    .HorizontalAlignment = xlCenter

    .VerticalAlignment = xlCenter

End With
End Sub
I have pasted the same code in code format , pls go through it and help me out
 

siddhuprince86

New Member
ok, Understood , But Every 4 rows , a new details are entered , how can it pick up automatically and merge,
that was my point ,

76624

IF you see the above image , these details are directly captured from user form that it have created ,But i could not merge ,
for example in the supplier column , there are 2 details , it has to automatically merge every 4 rows , how can i pass a command to do it

Hope u can understand my problem
 

vletm

Excel Ninja
siddhuprince86
based Your sample file ...
You seems to use Table ... rows 3..4, but Your four data rows are outside of Your table ... why?
Is row 8 Your main data row?
... if so then where do belong rows 5..7? .... previous or where?
... if rows 5...7 belongs to Your data row ... then could those datas add in front of row 8 data .. or how?
Why do You've idea to merge something?
... as above, those few datas could add to row 8 and after that delete rows 5.. 7 ... if those belongs to that row.

based Your #4 ...
That looks different than Your file.
>> You should able to show - what do You really would like to get?
= add new expected results sheet to Your file, which shows clear Your expected solution to Your challenge.

There are 100 customer details like that
... why?
 
Top