I'm having trouble with a line of code. I want to select a column in a datasheet based on the FirstRow and LastRow, I can find the FirstRow and LastRow, I'm using the code below:
Firstrow = Cells(Rows.Count, 1).End(xlUp).End(xlUp).Row
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Rows(Firstrow & ":" & LastRow).Select
When I run this code, it selects the FirstRow and LastRow, but for all the columns. I need to use this to only select column G. I have tried adding this in the code:
Rows(Firstrow & "G:G" & LastRow).Select
But that gives me the error: Type mismatch.
I've also tried to make adjustments in the FirstRow and LastRow statement:
Firstrow = Cells(Rows.Count, 7).End(xlUp).End(xlUp).Row
LastRow = Cells(Rows.Count, 7).End(xlUp).Row
But that doesn't work either.
Anyone experienced with this? Preferably I want to be able to adjust the column in the select function, not the FirstRow and LastRow, because I need to select different columns later on.