Thread: what's wrong?
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
active_x[_13_] active_x[_13_] is offline
external usenet poster
 
Posts: 1
Default what's wrong?

what's wrong?

Example:
------------------------------------------------------------------------------------Sub
combine_cells()
Dim rngContent As Range
Dim rLastContent As Integer
Dim i As Integer

rLastContent = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) .Row

Set rngContent = Range("B4:G" & rLastContent)

Application.DisplayAlerts = False

For i = 4 To rLastContent
Range("B"&i&":"&"G"&i).Merge
Next

Application.DisplayAlerts = True

End Sub
------------------------------------------------------------------------------------The
above vba is supposed to run in this way:
merge B4:G4
merge B5:G5
merge B6:G6
...
However, NONE of the cells is merged! What's wrong? (question 1)
Can the vba be written in the form of: (question 2)
For Each ... In ...
...
Next
If yes, how to write? (question 3)



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/