PDA

View Full Version : If...Then...Else - Help!



haddy27
06-15-2007, 08:34 AM
I am writing a bit of code that uses different subroutines.

I only want one of the subroutines to execute if a given criteria is met, in my case, if cell is empty.

The code I have so far is below, but it's not working for me:

Sub ReloadAdditionalIncome()

Sheets("Reload Data").Select
If Range("A4") = "" Then Exit Sub


'reload additional income data
Sheets("Reload Data").Select
Range("A4:Y13").Copy
Sheets("USER INPUTS - Additional Income").Select
Range("F16").PasteSpecial Paste:=xlPasteValues
Sheets("USER INPUTS - Additional Income").Select
Range("F16").Select

end sub


I've tried the coding if range("A4") = "" then go to NextSubRoutine but this doesn't seem to be helping either.

This is the final stumbling block for this job so any help would be greatly appreciated.

Thanks

JKwan
06-15-2007, 08:40 AM
If range("A4").value = "" Then go To NextSubRoutine


You may need to .value at the end to check it.

ska67can
06-15-2007, 08:49 AM
If Range("A4").Value = "" Then GoTo NextSubRoutine



ska

Bob Phillips
06-15-2007, 10:43 AM
I think you would be better with logic along the lines of



Sub Overall()

ReloadAdditionalIncome
NextSubroutine
End Sub

Sub ReloadAdditionalIncome()

Sheets("Reload Data").Select

If Range("A4") = "" Then Exit Sub

'reload additional income data
Sheets("Reload Data").Select
Range("A4:Y13").Copy
Sheets("USER INPUTS - Additional Income").Select
Range("F16").PasteSpecial Paste:=xlPasteValues
Sheets("USER INPUTS - Additional Income").Select
Range("F16").Select

End Sub

Sub NextSubroutine()

End Sub