GossopsGreen
New Member
- Joined
- Jun 6, 2012
- Messages
- 4
Hello All,</SPAN></SPAN>
Can one of you intelligent people help me with a problem I am having on a macro please?</SPAN></SPAN>
I am trying to get an IF statement to run another sub but I cannot get it to work for some reason.</SPAN></SPAN>
Here's basically what I have at the moment……</SPAN></SPAN>
Public Sub CommandButton1_Click()</SPAN></SPAN>
Dim Period As String</SPAN></SPAN>
Period = Application.InputBox("Current Tax Period (in 2 digit format)")</SPAN></SPAN>
If Period <= "06" Then</SPAN></SPAN>
GetDates1</SPAN></SPAN>
ElseIf Period >= "07" Then</SPAN></SPAN>
GetDates2</SPAN></SPAN>
End If</SPAN></SPAN>
End Sub</SPAN></SPAN>
Public Sub GetDates1()</SPAN></SPAN>
If Period = "01" Then</SPAN></SPAN>
Sheets("010").Range("B4").Formula = "='F:\......\Richard\[Paygroup listing.xls]Paygroup Listing'!$G$25"</SPAN></SPAN>
ElseIf Period = "02" Then</SPAN></SPAN>
Sheets("010").Range("B4").Formula = "='F:\......\Richard\[Paygroup listing.xls]Paygroup Listing'!$H$25"</SPAN></SPAN>
End If</SPAN></SPAN>
End Sub</SPAN></SPAN>
I have spent a long time trawling through Google looking for a resolution but no such luck unfortunately.</SPAN></SPAN>
Is the IF statement in the wrong format? Is the "Period" string not automatically carried through to the other sub?</SPAN></SPAN>
At the moment, it does run through, without any errors, but it doesn't input the required formula's anywhere.</SPAN></SPAN>
As you can tell, I'm not the most experienced in VB so your help will be massively appreciated.
Richard</SPAN></SPAN>
Can one of you intelligent people help me with a problem I am having on a macro please?</SPAN></SPAN>
I am trying to get an IF statement to run another sub but I cannot get it to work for some reason.</SPAN></SPAN>
Here's basically what I have at the moment……</SPAN></SPAN>
Public Sub CommandButton1_Click()</SPAN></SPAN>
Dim Period As String</SPAN></SPAN>
Period = Application.InputBox("Current Tax Period (in 2 digit format)")</SPAN></SPAN>
If Period <= "06" Then</SPAN></SPAN>
GetDates1</SPAN></SPAN>
ElseIf Period >= "07" Then</SPAN></SPAN>
GetDates2</SPAN></SPAN>
End If</SPAN></SPAN>
End Sub</SPAN></SPAN>
Public Sub GetDates1()</SPAN></SPAN>
If Period = "01" Then</SPAN></SPAN>
Sheets("010").Range("B4").Formula = "='F:\......\Richard\[Paygroup listing.xls]Paygroup Listing'!$G$25"</SPAN></SPAN>
ElseIf Period = "02" Then</SPAN></SPAN>
Sheets("010").Range("B4").Formula = "='F:\......\Richard\[Paygroup listing.xls]Paygroup Listing'!$H$25"</SPAN></SPAN>
End If</SPAN></SPAN>
End Sub</SPAN></SPAN>
I have spent a long time trawling through Google looking for a resolution but no such luck unfortunately.</SPAN></SPAN>
Is the IF statement in the wrong format? Is the "Period" string not automatically carried through to the other sub?</SPAN></SPAN>
At the moment, it does run through, without any errors, but it doesn't input the required formula's anywhere.</SPAN></SPAN>
As you can tell, I'm not the most experienced in VB so your help will be massively appreciated.
Richard</SPAN></SPAN>