0

I am trying to make a compare file script that'll check for a certain ticketID on file 1 that isn't on file 2, and vice versa. That compare will add the whole row to a sheet if it wasn't found in a file. I have the data separated and have text that is a description for the first block of data (the IDs in file1 not in file2).

I have attached an image of what the current output looks like (I've erased the pertinent data but the data goes in the light grey lines). I have my code ordered to where I want to insert the description text for the second compare. So I check for last row after the first compare loop.

Sheets("Sheet3").Select
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1
ActiveSheet.Cells(LastRow, "A").Value = "here"
ActiveSheet.Cells(LastRow, "A").Select

My issue is that I don't know how to grab that range of cells. In my current output, I want to grab from (A15:P16), so two rows all the way to column P. I always know it'll be Row A and Column P, but I never know what row number. This is because when I compare files I won't know how many differences I will have and therefore how many rows are used in sheet3. Once I have this range selected or available, I'd like to put in my description text for the second block of data and be able to merge and indent and customize it so I can have it where I want. Then I will do the second compare and insert the data from file 2 not found in file1. So the main issue is I don't know how to grab that range of cells I want because I won't know the exact rows it'll be on.

Raj More
  • 47,048
  • 33
  • 131
  • 198
rdan1
  • 17
  • 6

1 Answers1

0

To select the range requested, I would use:

With ActiveSheet
    .Range("A4:P" & .cells(rows.count,1).end(xlup).row).Select
End with

I must recommend not selecting this range though. I recommend performing whatever action is necessary directly on the range.

With ActiveSheet
    .Range("A4:P" & .cells(rows.count,1).end(xlup).row).Merge
End with
Kyle
  • 2,543
  • 2
  • 16
  • 31