Posts by BenC1985

    Re: Looping Macro's with merged cells


    So for the second part, I have tried just duplicating the macro so writing:



    But that didn't work I can do this over 2 rows by using:


    Code
    Dim rng1 As Range
    Set rng1 = Intersect(Range("G16:Z16", "G19:Z19"), Target)
    If rng1 Is Nothing Then Exit Sub
    Application.EnableEvents = False
    rng1.Offset(2, 0).Value = Date & " - " & Environ("username")
    Application.EnableEvents = TrueEnd Sub


    but I can't get this to work for rows G22:Z22 - G313:Z313

    Re: Looping Macro's with merged cells


    Cytop, this works great!


    I was hoping that with a shorter macro, it wouldn't take as long but it seems to take around the same amount of time. It's a lot cleaner though, thank you!

    Hi all!


    I've only just registered today and new to VB macro's and just reading through other peoples posts on here has helped me get as far as I have, but I still need a bit of help.


    I have created a spreadsheet that has a table of 100 rows, but I have had to merge the cells for this so it is really 300 rows. I put a macro in to hide each 3 rows when cell in column C was blank, because these are merged cells I don't think I can put a range into the macro, and I am unsure of how to loop the first macro to repeat every third row.


    Below is an example of the code, these steps go up to Row 316.



    I also have the same looping query about a different macro on the same sheet, this macro is to stamp the date and time into a cell, so when cell G16 - Z16 is changed, the cell 2 rows down is stamped with username and date. I can't seem to write this macro more than once for each row.


    Code
    'Macro to add Date and username into comments'
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng1 As Range
    Set rng1 = Intersect(Range("G16:Z16"), Target)
    If rng1 Is Nothing Then Exit Sub
    Application.EnableEvents = False
    rng1.Offset(2, 0).Value = Date & " - " & Environ("username")
    Application.EnableEvents = True
    End Sub


    Any help would be greatly appreciated!