-
Solved: Variables in String Issue
Hello everybody. Thanks for taking the time to look at my issue.
Going to use just examples to get my general problem across. The problem is as such...
I have a public variable lets call "PublicVariable" that I'm using across two subs.
Dim PublicVariable as String
In Sub1 I have...
PublicVariable = """=(35*(5-H"" & LastRow2 & ""))-H"" & LastRow1"
LastRow2 and LastRow1 being variables from a previous calculation for the last row and the last row + 1. But that doesn't really matter. They are just variables.
In Sub2 I have...
Cells(2, 10).Formula = PublicVariable
What happens is, instead of Cells(2,10) getting this for a formula....
=(35*(5-H2))-H1
it gets this for a formula...
"=(35*(5-H" & LastRow2 & "))-H" & LastRow1
The exact text without the variables and such calculated.
I've also tried this...
PublicVariable = "=(35*(5-H" & LastRow2 & "))-H" & LastRow1
but then all I get in Cells(2,10) is...
=(35*(5-H
Now if I manually plugged in the string into Sub2 like this...
Cells(2, 10).Formula = "=(35*(5-H" & LastRow2 & "))-H" & LastRow1
then it works.
So I need to find a way to put my string into a variable form that allows it to be used later and properly come together to create the PROPER final result in Cells(2,10) like this...
=(35*(5-H2))-H1
Do I need to dim PublicVariable as something besides string?
Am I being clear? Let me know if I need to clarify anything.
Thanks!
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