VBA to Select variable rows across columns

时间:2017-06-04 23:45:30

标签: excel vba excel-vba

current code is

lngLastRowDPWK = ActiveSheet.Cells(Activesheet.Rows.Count,"DX".End(xlUP).Row+3

Range("DP" & lngLastRowDPWK:"DV" & lngLastRowDPWK +2).select

I'm wanting it to highlight a few rows of in columns DP-DV but the row number is a variable. Any help is appreciated. Thank you

1 个答案:

答案 0 :(得分:1)

Sub test()
    'You were missing a ")"
    lngLastRowDPWK = ActiveSheet.Cells(ActiveSheet.Rows.Count, "DX").End(xlUp).Row + 3
    'You weren't creating the string correctly
    Range("DP" & lngLastRowDPWK & ":DV" & lngLastRowDPWK + 2).Select
End Sub