Problems accessing names across worksheets

  • Thread starter Thread starter alexander.krol
  • Start date Start date
A

alexander.krol

(also posted on microsoft.public.excel.misc)

Hi-

Having a problem with accessing the "alpha1" name below (defined in
sheet "Data") while running this simple macro in sheet "Calc" - excel
gives me a runtime 1004 error:

(fyi - never used VB before this, so that may be the problem ;)

Essentially, there is no problem accessing both "step_inp" or "stat1"
since the macro is run from the "Calc" worksheet, but it breaks on the
line marked with the ** - how do I fix this?

Begin Code:
-----------------

Sub Permute()

Dim Step As Double
Dim Inpt As Range
Dim Loc As Range

Sheets("Calc").Range("step_inp").Select
Step = ActiveCell.Value
Set Inpt = Sheets("Data").Range("alpha1")
Set Loc = Sheets("Calc").Range("stat1")

**Inpt.Select**
ActiveCell.Value = -1 * Step

For i = 0 To Round(80 / (Step * 100))
Inpt.Select
ActiveCell.Value = ActiveCell.Value + Step
Loc.Select
Selection.Copy
Loc.Offset(i + 1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next i

End Sub
________
End Code

Any help is much appreciated.

Thanks,
-Alex
 
There are other problems and revisions available but to answer your
question, you cannot SELECT a range on another sheet. You must either select
the sheet first and then select the range or simply use application.goto

However, selections are rarely necessary or desirable. You need post in ONLY
one group but ,since you did, it's nice that you said you posted elsewhere.
 
Since a range name is defined try these instead

Step = Range("step_inp")
Set Inpt = Range("alpha1")
Set Loc = Range("stat1")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top