G
Guest
H
Firstly, a bit of background about what I'm trying to do
I've got a Word mailmerge and the datasource is in excel. I'm trying to write a bit of code which goes to the last row in excel, and then hides all of the blank rows that appear after this. The code that I have done already is
Su
ActiveCell.Cells.Selec
Cells.Selec
Selection.EntireRow.Hidden = Fals
Range("A1").Selec
Selection.End(xlDown).Selec
Range("A" & ActiveCell.Row + 1).Selec
****************************
Selection.End(xlDown).Selec
Selection.EntireRow.Hidden = Tru
End Su
Where **** is, is where I'm stuck. The last row on the spreadsheet is variable which is why I use Ctrl+xlDown to get to it from "A1". If I was doing this manually, I'd press Ctrl+Shift+xlDown which would highlight the rest of the spreadsheet, then I could format/rows and hide the rows that appear after the last record. Does anyone know how I can do this in code? When I record a macro it just gives me the range that I've selected but I need some code that will go from the active cell, to the end of the spreadsheet
Firstly, a bit of background about what I'm trying to do
I've got a Word mailmerge and the datasource is in excel. I'm trying to write a bit of code which goes to the last row in excel, and then hides all of the blank rows that appear after this. The code that I have done already is
Su
ActiveCell.Cells.Selec
Cells.Selec
Selection.EntireRow.Hidden = Fals
Range("A1").Selec
Selection.End(xlDown).Selec
Range("A" & ActiveCell.Row + 1).Selec
****************************
Selection.End(xlDown).Selec
Selection.EntireRow.Hidden = Tru
End Su
Where **** is, is where I'm stuck. The last row on the spreadsheet is variable which is why I use Ctrl+xlDown to get to it from "A1". If I was doing this manually, I'd press Ctrl+Shift+xlDown which would highlight the rest of the spreadsheet, then I could format/rows and hide the rows that appear after the last record. Does anyone know how I can do this in code? When I record a macro it just gives me the range that I've selected but I need some code that will go from the active cell, to the end of the spreadsheet