shapeshiftingkiwi
New Member
- Joined
- Mar 31, 2021
- Messages
- 33
- Office Version
- 365
- Platform
- Windows
I'm trying to combine two macros to one command button but am getting Compile Error: Expected: Expression as an error. Here's what I'm trying to run...
Private Sub RunAllMacros()
CammandButton1_Click
HideRows_Based_On_Values
End Sub
Private Sub CommandButton1_Click()
Sheets("Form").Range("D7").Value = ""
Sheets("Form").Range("D9:D10").Value = ""
Sheets("Form").Range("F14:F29").Value = ""
Sheets("Form").Range("G14:G29").Value = ""
Sheets("Form").Range("C32:C39").Value = ""
Sheets("Form").Range("D32:D39").Value = ""
Sheets("Form").Range("F32:F39").Value = ""
Sheets("Form").Range("D43:D44").Value = ""
Sheets("Form").Range("H43:H44").Value = ""
Sheets("Form").Range("K43:K44").Value = ""
Sheets("Form").Range("D48").Value = ""
Sheets("Form").Range("I48").Value = ""
Sheets("Form").Range("D5").Value = ""
Sheets("Form").Range("D56").Value = ""
Sheets("Form").Range("I56").Value = ""
Sheets("Form").Range("D51:D52").Value = ""
Sheets("Form").Range("H51:H52").Value = ""
Sheets("Form").Range("K51:K52").Value = ""
Sheets("Form").Range("H5").Value = ""
Sheets("Form").Range("J5").Value = ""
MsgBox "Form has been reset"
End Sub
Private Sub HideRows_Based_On_Values()
For Each cell In Range("D14:D33")
If cell.Value = "-" Then cell.EntireRow.Hidden = True
If cell.Value <> "-" Then cell.EntireRow.Hidden = False
End Sub
End Sub
If this code looks like absolute trash, please forgive me, this is all very new to me!
Thanks for any help!
Private Sub RunAllMacros()
CammandButton1_Click
HideRows_Based_On_Values
End Sub
Private Sub CommandButton1_Click()
Sheets("Form").Range("D7").Value = ""
Sheets("Form").Range("D9:D10").Value = ""
Sheets("Form").Range("F14:F29").Value = ""
Sheets("Form").Range("G14:G29").Value = ""
Sheets("Form").Range("C32:C39").Value = ""
Sheets("Form").Range("D32:D39").Value = ""
Sheets("Form").Range("F32:F39").Value = ""
Sheets("Form").Range("D43:D44").Value = ""
Sheets("Form").Range("H43:H44").Value = ""
Sheets("Form").Range("K43:K44").Value = ""
Sheets("Form").Range("D48").Value = ""
Sheets("Form").Range("I48").Value = ""
Sheets("Form").Range("D5").Value = ""
Sheets("Form").Range("D56").Value = ""
Sheets("Form").Range("I56").Value = ""
Sheets("Form").Range("D51:D52").Value = ""
Sheets("Form").Range("H51:H52").Value = ""
Sheets("Form").Range("K51:K52").Value = ""
Sheets("Form").Range("H5").Value = ""
Sheets("Form").Range("J5").Value = ""
MsgBox "Form has been reset"
End Sub
Private Sub HideRows_Based_On_Values()
For Each cell In Range("D14:D33")
If cell.Value = "-" Then cell.EntireRow.Hidden = True
If cell.Value <> "-" Then cell.EntireRow.Hidden = False
End Sub
End Sub
If this code looks like absolute trash, please forgive me, this is all very new to me!
Thanks for any help!