Excel VBA - Put value in destination cell in another worksheet

I'm trying to put a value into a cell in another worksheet (same workbook) without selecting that other wks.
My code below is not working...

Sub M_PutValueInOtherWks()
    Dim vDestRow As Integer
    Dim vDestCol As Integer
   
    vDestCol = 4
    vDestRow = 114
   
       Sheet3.Range(Cells(vDestRow, vDestCol), Cells(vDestRow, vDestCol)).Value = "XYZ"

'// this alternative line of code doesn't work either...
        Sheet3.Cells(vDestRow, vDestCol).Value = "XYZ"


End Sub

AndresHernandoAsked:
Who is Participating?
 
Saqib Husain, SyedConnect With a Mentor EngineerCommented:
Try
Sheet3.Range(Cells(vDestRow, vDestCol).Address & ":" & Cells(vDestRow, vDestCol).Address).Value = "XYZ"

Open in new window

0
 
AndresHernandoAuthor Commented:
BTW, I'm calling this from Sheet1 code (not module)
0
 
Rory ArchibaldCommented:
In what way does:
Sheet3.Cells(vDestRow, vDestCol).Value = "XYZ"
not work? It should assuming that Sheet3 is the correct code name (not sheet caption) and that the sheet is not protected.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Arno KosterCommented:
you can use

Sheet3.range("D114")= "XYZ"
0
 
Arno KosterCommented:
or

Sheets(3).range("D114") = "XYZ"

or even

Sheets("Sheet3").range("D114") = "XYZ"
0
 
AndresHernandoAuthor Commented:
Worked like a charm!  Thanks!!!  --Andres
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.