wb.Worksheets(1).Range("A17", "B18", "R19", "S20").Value = "OK" Does not work

i want to use vba to update these non adjacent cells value to "OK"  but this method is not working

wb.Worksheets(1).Range("C17", "C18", "C19", "C20").Value = "OK"

how can i make this work?
LVL 3
excelismagicAsked:
Who is Participating?
 
Subodh Tiwari (Neeraj)Connect With a Mentor Excel & VBA ExpertCommented:
You should try it like this..
wb.Worksheets(1).Range("C17, C18, C19, C20").Value = "OK"

Open in new window

Though the straightforward way would be this...
wb.Worksheets(1).Range("C17:C20").Value = "OK"

Open in new window

0
 
excelismagicAuthor Commented:
can this work even if it is non adjacent cells?

liek this Range("C17, D18, R11, W27")
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Yes, it will work in that case also.
0
All Courses

From novice to tech pro — start learning today.