last day (15 days later) » 

7:53 PM
2
A: Using VBA to indent parent child columns

RBarryYoungThe following Excel-VBA module works for me. Option Explicit Type Tree_Node ' note: and IDX of zero means that it does not exist. Idx As Long 'The array index of the original source record ParentIdx As Long 'The array index of the parent of this node Depth As Lo...

 
That doesn't work for me. When i attempt to run the macro, the function OutputIndentedRecords can't be called i.e. i don't see anything in the list.
 
You cannot call a subroutine with parameters as a plain old macro. I will post an example of how to cal it ...
 
Thanks RBarryYoung. I tried that and it crashes Excel as soon as i hit the button.
 
It works for me, could be a spelling or name problem. Try setting a break point on the first line and walking through it. Or else set "Break On All Errors" from the VBA Options dialog.
 
I also get the error 'Method or data member not found' at the line .IsParent = True
 
7:53 PM
Just delete that line. It was supposed to be removed.
OK
hello?
 
Now i get another error
Invalid procedure or call
I get it as soon as i delete that line
 
at what line?
 
.ParentIdx = PDataIdxs(CStr(src(i, PPackID)))
 
That should only cause an error if there is a value in PPackID, that was not already seen in PDATA.
 
It's exactly the same data i posted
 
8:02 PM
hang on ...
 
As noted in the code's comments, you need to only select the data. Do not include the column headers in the selection.
 
That works. Sorry about that. Is there a way to do it without selecting the data i.e. a selected range of columns?
 
How would it know where the data was then? If its always in the same place, then you could change the button macro to just hard code it..
 
The data would always be in the same worksheet e.g. "Source"
 
8:08 PM
OK, then that should work.
 
Is there an easy way to do it?
 
Does it also matter which columns the data reside it i.e. the sequence?
 
Yes. The column offsets are hardcoded in the Const definitions at the top of the routine.
If they change, you will need to change the offsets there.
 
Does it have to be PackName CPackID PPackID PName ParentID PDATA
Okay. Thanks so much
Appreciate your help
 
8:13 PM
no problem..
 

last day (15 days later) »