?
Solved

Excel VBA - Put value in destination cell in another worksheet

Posted on 2011-05-09
6
Medium Priority
?
768 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:AndresHernando
6 Comments
 

Author Comment

by:AndresHernando
ID: 35719421
BTW, I'm calling this from Sheet1 code (not module)
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 35719471
Try
Sheet3.Range(Cells(vDestRow, vDestCol).Address & ":" & Cells(vDestRow, vDestCol).Address).Value = "XYZ"

Open in new window

0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 35719490
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 19

Expert Comment

by:Arno Koster
ID: 35719621
you can use

Sheet3.range("D114")= "XYZ"
0
 
LVL 19

Expert Comment

by:Arno Koster
ID: 35719629
or

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

or even

Sheets("Sheet3").range("D114") = "XYZ"
0
 

Author Closing Comment

by:AndresHernando
ID: 35719857
Worked like a charm!  Thanks!!!  --Andres
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question