1

I am trying to dynamically populate a worksheet with data from a different sheet. I am trying to find the last populated column of every row and then add the data to the right of the last populated column. Each row may have multiple entries on the other sheet and so I have a For loop to add data to the right. But my code is taking the last column from the previous loop run, increments it, populating the sheet in a ladder fashion. XXXX YYYYY ZZZZZZ I want the code to populate as such: XXXX YYYY ZZZZ WWWW

Here is the code:

Set wsLD = Worksheets("ListDir")
Set wsTO = Worksheets("Requirements To Be Certified")
intLastLDRow = wsLD.Cells(Rows.count, 1).End(xlUp).Row

 For intLooper = 2 To intLastLDRow
    intReqRowNum = wsLD.Cells(intLooper, 1).Value
    wsTO.Cells(1, 1).Activate
    intLastTOCol = wsTO.Cells(intReqRowNum, wsTO.Columns.count).End(xlToLeft).Column

    wsTO.Cells(intReqRowNum, intLastTOCol + 1).Value = wsLD.Cells(intLooper, 5).Value
    wsTO.Hyperlinks.Add Anchor:=wsTO.Cells(intReqRowNum, intLastTOCol + 1), _
            Address:=wsLD.Cells(intLooper, 4).Value, TextToDisplay:=wsLD.Cells(intLooper, 5).Value

Next intLooper

I am not trying to select a range or activate any other cell - and that is how it makes it different.

I E
  • 11
  • 2

0 Answers0