Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
accessuser1308
 
Posts: n/a
Default Looping macros using VB code

I am trying to loop a macro in excel. The macro will merge, for example,
cells F3:H3. I want the macro to perform the merge for all rows that have
data in column F. Does anybody know what code will make this work? Thanks
in advance.
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Mergedcells can break lots of things. I only use them when I really, really
have to.

But how about something like:

Option Explicit
Sub testme01()

Dim myCell As Range
Dim myRng As Range

With ActiveSheet
Set myRng = .Range("f1", .Cells(.Rows.Count, "F").End(xlUp))
End With

For Each myCell In myRng.Cells
If IsEmpty(myCell) Then
'do nothing
Else
Application.DisplayAlerts = False
myCell.Resize(1, 3).Merge
Application.DisplayAlerts = True
End If
Next myCell

End Sub


accessuser1308 wrote:

I am trying to loop a macro in excel. The macro will merge, for example,
cells F3:H3. I want the macro to perform the merge for all rows that have
data in column F. Does anybody know what code will make this work? Thanks
in advance.


--

Dave Peterson
  #3   Report Post  
accessuser1308
 
Posts: n/a
Default

This did exactly what I needed. Thank you very much

"accessuser1308" wrote:

I am trying to loop a macro in excel. The macro will merge, for example,
cells F3:H3. I want the macro to perform the merge for all rows that have
data in column F. Does anybody know what code will make this work? Thanks
in advance.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 7 March 7th 05 06:29 PM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 4th 05 10:50 AM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 3rd 05 03:40 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 0 February 28th 05 06:26 PM
The available macros list in XL; how to suppress filename from showing KR Excel Discussion (Misc queries) 1 January 10th 05 07:20 PM


All times are GMT +1. The time now is 10:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"