+ Reply to Thread
Results 1 to 3 of 3

Looping macros using VB code

  1. #1
    accessuser1308
    Guest

    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. #2
    Dave Peterson
    Guest

    Re: Looping macros using VB code

    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. #3
    accessuser1308
    Guest

    RE: Looping macros using VB code

    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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1