Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default setting first empty cell as range


Hi everyone,

I have a Macro that imports data from an access table. What i want to
do is add the data from the table into the first empty cell after the
data that is already on the worksheet.

i tried setting a marco to select the first empty cell when the
worksheet loads, but the import macro keeps going to a specific cell
anyway.

here is the marco i use:


Code:
--------------------
Sub importtable()

With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=" """;User ID=Admin;Data Source=H:\Monthly Stat Project\STATTEST.mdb;Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("A3496"))
.CommandType = xlCmdTable
.CommandText = Array("CurrentMonth")
.Name = "STATTEST CurrentMonth_6"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceConnectionFile = "H:\Data\My Data Sources\STATTEST CurrentMonth.odc"
.SourceDataFile = "H:\Monthly Stat Project\STATTEST.mdb"
.Refresh BackgroundQuery:=False
End With
End Sub
--------------------



i need to get the "destination range" to be the first empty cell after
the exsiting data on the spreadsheet.

Any help would be appreciated!


--
captainwicked
------------------------------------------------------------------------
captainwicked's Profile: http://www.excelforum.com/member.php...o&userid=36369
View this thread: http://www.excelforum.com/showthread...hreadid=561534

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default setting first empty cell as range

You want code something like this... It creates a range object at the first
empty cell in column A of the active sheet.

dim rngDestination as Range

Set rngDestination = cells(rows.count, "A").end(xlUp).offset(1,0)

--
HTH...

Jim Thomlinson


"captainwicked" wrote:


Hi everyone,

I have a Macro that imports data from an access table. What i want to
do is add the data from the table into the first empty cell after the
data that is already on the worksheet.

i tried setting a marco to select the first empty cell when the
worksheet loads, but the import macro keeps going to a specific cell
anyway.

here is the marco i use:


Code:
--------------------
Sub importtable()

With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=" """;User ID=Admin;Data Source=H:\Monthly Stat Project\STATTEST.mdb;Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("A3496"))
.CommandType = xlCmdTable
.CommandText = Array("CurrentMonth")
.Name = "STATTEST CurrentMonth_6"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceConnectionFile = "H:\Data\My Data Sources\STATTEST CurrentMonth.odc"
.SourceDataFile = "H:\Monthly Stat Project\STATTEST.mdb"
.Refresh BackgroundQuery:=False
End With
End Sub
--------------------



i need to get the "destination range" to be the first empty cell after
the exsiting data on the spreadsheet.

Any help would be appreciated!


--
captainwicked
------------------------------------------------------------------------
captainwicked's Profile: http://www.excelforum.com/member.php...o&userid=36369
View this thread: http://www.excelforum.com/showthread...hreadid=561534


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
If cell not empty, then display from range puiuluipui Excel Discussion (Misc queries) 7 October 3rd 09 08:01 PM
setting a cell to 'empty' or blank or null ? KRK New Users to Excel 7 May 7th 08 12:49 AM
Finding next empty empty cell in a range of columns UncleBun Excel Programming 1 January 13th 06 11:22 PM
Range - setting a value in a cell cantonarv Excel Programming 1 November 22nd 05 01:12 PM
Setting a range with the last used cell? andycharger[_42_] Excel Programming 2 July 2nd 04 09:43 PM


All times are GMT +1. The time now is 08:01 PM.

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

About Us

"It's about Microsoft Excel"