Target Offset on another work sheet

Hi all,

Simple question today for you; me?  Not so simple.

So I have 1 workbook open and I am trying to work in between the different sheets.

This little bit of code has me tricked up; this code is in a larger piece of code so we need not worry about what is ahead or behind it, I just can't debug this thing.

Worksheets("sheets2").range(target.address).offset(0,15).value = "21"

So I am on one sheet and want to make the offset cell = 21.

The sheet name where I want the 21 to go to is called "test5" and is but is actually "sheet2" so I don't know if that matters.

Other than that my excel says I need to debug this.

Any thoughts?

thanks,

BB
BostonBobAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

byundtMechanical EngineerCommented:
If you don't have a worksheet with a tab name "sheets2", you will get a runtime error on the statement indicated.

If I understand your question correctly, the worksheet has a tab name of "test5" and a codename of Sheet2. In the VBA Editor in the Project Explorer pane on the left, you should see the worksheet listed as "Sheet2 (test5)".

You should be able to use either of the following--but most people find the second approach less confusing. Note that I removed the doublequotes from "21", as I suspect that you want the cell to contain a number rather than text that looks like a number.
Sheet2.Range(Target.Address).Offset(0,15).Value = 21
Worksheets("test5").Range(Target.Address).Offset(0,15).Value = 21

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.