A bigger vba program goes to a named range, inserts variable number of records each day at named range1, then directly below to namedrange 2.
Now, I want to take just the data of namedrange1, 2 and union them on a new worksheet to re-sort both.
Updated the code - go to two named ranges - pick current region - remove the header for each - create a new named range - union the two selections.
Code:Sub TryCurrentRange() ' InsertData & InsertData BG - want just data (no headers) concatenated ' Pasted on new worksheet, then resort on column 3 (not yet shown in this code) Dim Tbl As Range Application.Goto Reference:="InsertData" 'copyfromrecordset added x records Set Tbl = ActiveCell.CurrentRegion Tbl.Offset(1, 0).Resize(Tbl.Rows.Count - 1, Tbl.Columns.Count).Select ActiveWorkbook.Names.Add "InvGrNoHeaderF", Selection 'this created InvGrNoHeaderE - no header Application.Goto Reference:="InsertDataBG" 'copyfromrecordset added y records Set Tbl = ActiveCell.CurrentRegion Tbl.Offset(1, 0).Resize(Tbl.Rows.Count - 1, Tbl.Columns.Count).Select ActiveWorkbook.Names.Add "InvBGrNoHeaderF", Selection 'Union - concatenate two ranges (ranges have only data, no header) Union(Range("InvGrNoHeaderF"), Range("InvBGrNoHeaderF")).Select ' goto a namedrange on new workbook --I still need to insert this union End Sub
Last edited by RxMiller; 07-09-2009 at 04:20 PM. Reason: found better solution - much shorter
Rx, edit that first post and slip the / inside the code tag, so it looks like this at the end:
[/code]
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
I can't seem to add a new named ragne using ActiveWorkbook.Names.Add Name
Usintg CurrentRegion, I select the data with the header
use Offset to resize and remove the headeer
Now, I need to add a named range with only the data minus the header
If I can name two ranges of data only - untion them - goto the next location and insert the union data...
it might be short and sweet
Code:Sub TryCurrentRange() Dim Tbl As Range Application.Goto Reference:="InsertData" 'a copyfromrecordset added x number of records Set Tbl = ActiveCell.CurrentRegion ' this selects my data --- and the header above Tbl.Offset(1, 0).Resize(Tbl.Rows.Count - 1, Tbl.Columns.Count).Select ' this should remove the header row ActiveWorkbook.Names.Add Name:="InvGrNoHeaderA", '???? ' ' new named range - with out a header ' wich named parameter allows me to create a InvGrNOHEADERa named range from Tbl ?
Last edited by RxMiller; 07-09-2009 at 03:45 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks