#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 337
Default Database add

I have the following macro that adds a record to the database "TimeRecords"

Application.Goto Reference:="Export_Data"
Selection.Copy
Application.Goto Reference:="PT_Data" 'first row of database
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate

Selection.PasteSpecial Paste:=xlValues

My problem is the database range does not expand to add this record
I do not want to use the database form to add this record

oldjay
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,290
Default Database add

Set an object reference to the TimeRecords range.
Copy and paste the data.
Delete the TimeRecords name object.
Recreate the TimeRecords name using the range object (resized with one additional row).
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Sub ExpandRangeWhenRowInserted()
'Jim Cone - San Francisco, USA - Oct. 2006
Dim rngTemp As Excel.Range
Set rngTemp = Range("TimeRecords")
Set rngTemp = rngTemp.Resize(rngTemp.Rows.Count + 1)
Range("Export_Data").Copy
rngTemp(rngTemp.Rows.Count, 1).PasteSpecial Paste:=xlValues
Names("TimeRecords").Delete
Names.Add "TimeRecords", RefersTo:="=" & ActiveSheet.Name & "!" & rngTemp.Address
Application.CutCopyMode = False
Set rngTemp = Nothing
End Sub
'-------------



"Oldjay"
wrote in message
I have the following macro that adds a record to the database "TimeRecords"

Application.Goto Reference:="Export_Data"
Selection.Copy
Application.Goto Reference:="PT_Data" 'first row of database
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate

Selection.PasteSpecial Paste:=xlValues

My problem is the database range does not expand to add this record
I do not want to use the database form to add this record

oldjay
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 337
Default Database add

Worked great
Thanks

"Jim Cone" wrote:

Set an object reference to the TimeRecords range.
Copy and paste the data.
Delete the TimeRecords name object.
Recreate the TimeRecords name using the range object (resized with one additional row).
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Sub ExpandRangeWhenRowInserted()
'Jim Cone - San Francisco, USA - Oct. 2006
Dim rngTemp As Excel.Range
Set rngTemp = Range("TimeRecords")
Set rngTemp = rngTemp.Resize(rngTemp.Rows.Count + 1)
Range("Export_Data").Copy
rngTemp(rngTemp.Rows.Count, 1).PasteSpecial Paste:=xlValues
Names("TimeRecords").Delete
Names.Add "TimeRecords", RefersTo:="=" & ActiveSheet.Name & "!" & rngTemp.Address
Application.CutCopyMode = False
Set rngTemp = Nothing
End Sub
'-------------



"Oldjay"
wrote in message
I have the following macro that adds a record to the database "TimeRecords"

Application.Goto Reference:="Export_Data"
Selection.Copy
Application.Goto Reference:="PT_Data" 'first row of database
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate

Selection.PasteSpecial Paste:=xlValues

My problem is the database range does not expand to add this record
I do not want to use the database form to add this record

oldjay

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
Database Link Ed Excel Discussion (Misc queries) 2 April 24th 06 06:43 AM
Calculate Total Sales from a Database John Excel Worksheet Functions 0 November 3rd 05 12:26 PM
Database functions should use criteria in formula, as 1-2-3 does 123user Excel Worksheet Functions 8 September 29th 05 08:57 PM
Links to External Database Rubble Excel Discussion (Misc queries) 0 July 20th 05 10:44 PM
The Template Wizard retains the original location for my database Packwood Excel Discussion (Misc queries) 0 April 15th 05 05:25 PM


All times are GMT +1. The time now is 10:03 AM.

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"