Forum Discussion

Harry1605's avatar
Harry1605
Copper Contributor
Aug 20, 2022
Solved

Populate Group Details

Hello,

 

I have a table with 3,216 columns starting from row 4 it goes down to row 40.  The odd number columns hold email addresses, the even number columns are blank but on row 3 they have a group name (odd columns row  3 are blank).

The first column has the maximum (36) number of email addresses and they than vary in number of rows populated down to one.  How can I populate the group name down to align where there is an email in the left (odd number) column?  Thanks 

  • Harry1605 

    Run this macro:

    Sub FillGroup()
        Dim c As Long
        Dim n As Long
        Dim m As Long
        Application.ScreenUpdating = False
        n = Cells(3, Columns.Count).End(xlToLeft).Column
        For c = 2 To n Step 2
            m = Cells(Rows.Count, c - 1).End(xlUp).Row
            Cells(4, c).Resize(m - 3).Value = Cells(3, c).Value
        Next c
        Application.ScreenUpdating = True
    End Sub
  • Harry1605's avatar
    Harry1605
    Copper Contributor
    Hans, Thank you so much you are a life saver. I have another ask but will post a seperate question. Do I award points or anything for the solution you have provided?
  • Harry1605 

    Run this macro:

    Sub FillGroup()
        Dim c As Long
        Dim n As Long
        Dim m As Long
        Application.ScreenUpdating = False
        n = Cells(3, Columns.Count).End(xlToLeft).Column
        For c = 2 To n Step 2
            m = Cells(Rows.Count, c - 1).End(xlUp).Row
            Cells(4, c).Resize(m - 3).Value = Cells(3, c).Value
        Next c
        Application.ScreenUpdating = True
    End Sub

Resources