call macro and user defined fields.

culcuhain

New Member
Joined
Apr 28, 2010
Messages
21
Good afternoon,
I have my macro that has a field created called (not via a DIM statement) Department.

A little ways into the Macro I have an IF THEN ELSE statement that CALLS another macro. I get a runtime error 424 when I try to populate my data with the value of Department.

So I have 2 questions.
1. Do I have to restate the value of Department in the called macro?
2. Should I have declared that variable instead? (DIM)

thanks!!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
here is a snipit from the main macro

Code:
For Each Department In Range("J2:J" & Range("J" & Rows.Count).End(xlUp).Row)
Range("G5").Value = Department
ApptFlag = Range("G9").Value

here is where I call the macro a little later:

Code:
If ApptFlag = "Y" Then
    Call ApptSummary
Else
    Sheets("Dept Appt").Visible = False
End If

and here is where I get the runtime Error

Code:
Sheets("Dept Appt").Visible = True
    Sheets("Dept Appt").Select
    Cells.Select
    Selection.EntireRow.Hidden = False
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Department"). _
    CurrentPage = Department.Value
    Cells.Select

It has the ActiveSheet.PivotTables line highlighted.

It worked fine until I tried to break out the section into a new macro.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,224,513
Messages
6,179,214
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top