ChristineJ
Well-known Member
- Joined
- May 18, 2009
- Messages
- 775
- Office Version
- 365
- Platform
- Windows
I'd like some help with using a variable in VBA for the abbreviated sample code below.
First, I have three macros, listed below. All do different things and work fine.
Sub Feedback_P10()
Sub Feedback_P12()
Sub Feedback_P15()
This following macro checks a cell in row P to see if there is a formula and returns "Yes" in column C in the same row if there is one.
The code below first calls Formula_P for cell P10.
Sub RESULTS()
Call Formula_P(10)
Call Feedback_P10 Is there a way to make this "10" a variable?
End Sub
Here is what I would like to happen using a variable in the Feedback macro:
If Call Formula_P(10) is in the RESULTS macro, the Feedback_P10() should also be called.
If Call Formula_P(12) is in the RESULTS macro, the Feedback_P12() should also be called.
If Call Formula_P(15) is in the RESULTS macro, the Feedback_P15() should also be called.
Thanks!
First, I have three macros, listed below. All do different things and work fine.
Sub Feedback_P10()
Sub Feedback_P12()
Sub Feedback_P15()
This following macro checks a cell in row P to see if there is a formula and returns "Yes" in column C in the same row if there is one.
Code:
Sub Formula_P(rowNum As Integer)
Dim rowNumber As Integer
Dim columnNumber As Integer
rowNumber = rowNum
If Range("P" & rowNumber).HasFormula = True Then
Range("C" & rowNumber).Value = "Yes"
End If
End Sub
The code below first calls Formula_P for cell P10.
Sub RESULTS()
Call Formula_P(10)
Call Feedback_P10 Is there a way to make this "10" a variable?
End Sub
Here is what I would like to happen using a variable in the Feedback macro:
If Call Formula_P(10) is in the RESULTS macro, the Feedback_P10() should also be called.
If Call Formula_P(12) is in the RESULTS macro, the Feedback_P12() should also be called.
If Call Formula_P(15) is in the RESULTS macro, the Feedback_P15() should also be called.
Thanks!