|
-
Jan 18th, 2006, 12:12 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Linking cells from other sheets formula (EXCEL)
Hi,
I'm getting a run time error 1004
Application-defined or object-defined error
What I'm trying to do is to link the value from another sheet.
The error is raised at: ActiveCell.Offset...... line
VB Code:
Sub Linker(Dis As String)
TDis = Dis
With Sheets("Total").Range("A1:A500")
Set b = .Find(TDis) 'Find the district
aadd = b.Address
End With
Sheets("Total").Select
ActiveSheet.Range([aadd]).Activate
'Put the formulas where it should be
ActiveCell.Offset(0, 2).Formula = "= " & TDis & " ! " & gtotactsalesw & " "
End Sub
The name of the sheet is coming by Dis who is a String
gtotactsalesw is also a String
Usually in an excel cell you link a value from another by entering the formula =sheet!cell
But don't seems to do the trick here.
Any help or hint would be appreciated.
thanks
-
Jan 18th, 2006, 12:41 PM
#2
Fanatic Member
Re: Linking cells from other sheets formula (EXCEL)
I didn't verify, but I believe you activate sheets and select ranges, not the other way around. Also, you don't need to select/activate to change the formula. You could use:
Sheets("Total").Range([aadd]).Offset(0, 2).Formula = "= " & TDis & " ! " & gtotactsalesw & " "
P.S. why use [aadd] instead of just aadd?
-
Jan 18th, 2006, 12:44 PM
#3
Lively Member
Re: Linking cells from other sheets formula (EXCEL)
What is the value in TDis? If the sheet name contains spaces you need to enclose it in single quotes.
vs.And out of curiosity, what is the purpose of the trailing space in the derived formula?
-
Jan 18th, 2006, 12:59 PM
#4
Thread Starter
Addicted Member
Re: Linking cells from other sheets formula (EXCEL)
VbHack: I use [aadd] because if I just use aadd it does't work at all. Also Sheets("Total").Range([aadd]).Offset(0, 2).Formula = "= " & TDis & " ! " & gtotactsalesw & " " does't seem to work.
The error seems to be on the right side of the = sign.
mickeyc1204: you're right again my friend...
TDis contains : "North S. & Outaouais"
the space between words is the problem.
And the trailing space were mistyping...
Work perfectly
Thanks again mickey1204
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|