• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 588
  • Last Modified:

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?


1 Solution
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

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.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now