0

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

user3066795
  • 41
  • 2
  • 10

1 Answers1

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
YowE3K
  • 23,852
  • 7
  • 26
  • 40
  • Range("DP" & lngLastRowDPWK & ":" & "DV" & lngLastRowDPWK +2).select – user3066795 Jun 04 '17 at 23:53
  • Thank you I found that variation as well at the same time. I will use yours in my code though thanks for the help – user3066795 Jun 04 '17 at 23:58
  • @user3066795 - Why are you selecting the data? FYI it's best to [avoid using `.Select`/`.Activate](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros) – BruceWayne Jun 05 '17 at 00:05