Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Adding data to end of range

I recorded the following macro that runs a query.

With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;C:\PathtoQuery\ClientTracking.dqy" _
, Destination:=Range("b3"))
.Name = "ClientTracking_1"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

Is there some way I can make the Range portion of the macro user-
selectable? I need to be able to add rows of data to the sheet
one at a time.

I'm thinking of the way that Excel displays a listbox that lets
you return to the sheet and select a cell which is then used in the
listbox. The formulabuilding tool is one place where you see this box.

I haven't a clue what it's called in VBA nor how to use it.

I guess an alternative would be if there's a way to automatically
detect the size of the range of data (it's not named right now)
and automatically append the returned data to the end of the
range.

Thanks.

gary
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Adding data to end of range

I should have mentioned that the data from the query will always
start in column B and that field will never contain a null.

g-
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Adding data to end of range

Thanks, Tom. Typing in the code works to this point
(the VB editor pops up the possible selections)

Destination:=Cells(rows.count,"B").End(xlup).offse t(1,0)
^^^^^^^^^^^^^^^^^^^^^^
The marked section causes a compiler error.

gary

"Tom Ogilvy" wrote in news:#HX2XpUXDHA.2256
@TK2MSFTNGP10.phx.gbl:

With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;C:\PathtoQuery\ClientTracking.dqy" _
, Destination:=Cells(rows.count,"B").End(xlup).offse t(1,0)
.Name = "ClientTracking_1"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

Might be what you want.

Regards,
Tom Ogilvy

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a range Josh Excel Discussion (Misc queries) 1 November 2nd 09 11:15 PM
a simple 'sum' formula is not adding all of the data in range Wild Cherry Excel Discussion (Misc queries) 2 July 7th 09 05:10 AM
Revisit an older post, looking for SQL help on adding range data frommany sheets to a single sheet Rick[_10_] Excel Worksheet Functions 4 May 31st 09 09:02 PM
Adding Data to a Non-Contiguous Range in Excel 2007 Tripp Martin Charts and Charting in Excel 1 November 12th 08 09:47 PM
Adding Data from Date Range base on relative dates GaryS Excel Worksheet Functions 1 May 1st 08 10:16 AM


All times are GMT +1. The time now is 07:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"