Macro Variable doubt

karti1986

Board Regular
Joined
Jun 24, 2014
Messages
60
Dim sel As Long
Range("B9").Select
Range(Selection, Selection.End(xlToRight)).Select
sel = Selection.Columns.Count
ActiveSheet.PivotTables("EventPivot").PivotFields("Hosts").AutoSort _
xlDescending, "Count of Incident.Incident ID", ActiveSheet.PivotTables( _
"EventPivot").PivotColumnAxis.PivotLines("sel"), 1


"sel" is this even possible here? Yes, it didnt work.. Please let me know how to make it work with any syntax corrections
sorry if Im dumb.

Thanks in advance!!

Regards
KG
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Dim sel As Long
Range("B9").Select
Range(Selection, Selection.End(xlToRight)).Select
sel = Selection.Columns.Count
ActiveSheet.PivotTables("EventPivot").PivotFields("Hosts").AutoSort _
xlDescending, "Count of Incident.Incident ID", ActiveSheet.PivotTables( _
"EventPivot").PivotColumnAxis.PivotLines("sel"), 1

"sel" is this even possible here? Yes, it didnt work.. Please let me know how to make it work with any syntax corrections
sorry if Im dumb.
Try removing the quote marks from around the variable name (sel) and see if that works.
 
Upvote 0
Thanks for the reply Rick

Tried that, it throws an error saying "Invalid Procedure Call or Argument"

Any Idea?

Thanks Again!

Regards
KG
 
Upvote 0
Thanks for the reply Rick

Tried that, it throws an error saying "Invalid Procedure Call or Argument"
Sorry, but I don't program with PivotTables... all I did was guess given that encasing variable names in quote marks hides the fact that they are variable names (and not just text) from the VB compiler. I don't know what kind of argument the PivotLines property is supposed to be looking for, but what you assigned to the "sel" variable appears not to be it. Hopefully someone with PivotTable experience will be along who can advise you better on this.
 
Upvote 0
Sorry, but I don't program with PivotTables... all I did was guess given that encasing variable names in quote marks hides the fact that they are variable names (and not just text) from the VB compiler. I don't know what kind of argument the PivotLines property is supposed to be looking for, but what you assigned to the "sel" variable appears not to be it. Hopefully someone with PivotTable experience will be along who can advise you better on this.


Im glad that you tried helping me! Thanks Rick!!
 
Upvote 0
I badly need this to work!! any alternative suggestions are welcomed as well!! Thanks
Why don't you post your original message in a new thread, but this time make the thread's title "PivotTable expert needed".
 
Upvote 0

Forum statistics

Threads
1,203,071
Messages
6,053,371
Members
444,658
Latest member
lhollingsworth

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