Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copy Data into Database gives error

I'm creating a macro to copy information entered into a form and
put it into a database. It works fine as long as the first row of
information is filled out in the database. If the no information has
been added to the database yet I get Run-Time Error 1004 Application
Defined or Object Defined Error. What can I change to correct this
from happening

Sheets("Form").Select
Range("A6:X20").Select
Selection.Copy
Sheets("Database").Select
Range("A10").Select
Selection.End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.End(xlDown).Select

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Copy Data into Database gives error

maybe add a :
If Range("A6:X20").value <"" then
Selection.Copy
Sheets("Database").Select
Range("A10").Select
Selection.End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.End(xlDown).Select
else
msgbox "There is No Value in the range !!"
end if

"bactfarmer" wrote in message
ups.com...
I'm creating a macro to copy information entered into a form and
put it into a database. It works fine as long as the first row of
information is filled out in the database. If the no information has
been added to the database yet I get Run-Time Error 1004 Application
Defined or Object Defined Error. What can I change to correct this
from happening

Sheets("Form").Select
Range("A6:X20").Select
Selection.Copy
Sheets("Database").Select
Range("A10").Select
Selection.End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.End(xlDown).Select



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy Data into Database gives error

Maybe you could start at the bottom of column A and go up to find the last used
cell in that row, then come down one row.

Dim RngToCopy as Range
Dim DestCell as range

with worksheets("form")
set rngtocopy = .range("a6:X20")
end with

with worksheets("Database")
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

rngtocopy.copy _
destination:=destcell



bactfarmer wrote:

I'm creating a macro to copy information entered into a form and
put it into a database. It works fine as long as the first row of
information is filled out in the database. If the no information has
been added to the database yet I get Run-Time Error 1004 Application
Defined or Object Defined Error. What can I change to correct this
from happening

Sheets("Form").Select
Range("A6:X20").Select
Selection.Copy
Sheets("Database").Select
Range("A10").Select
Selection.End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.End(xlDown).Select


--

Dave Peterson
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
Auto copy data from another database Montu Excel Worksheet Functions 0 January 24th 08 01:54 PM
How to make reference to database and if true copy from database? V!p3r Excel Discussion (Misc queries) 4 February 5th 07 02:19 PM
I have Error 1919 Error Configuring ODBC dataSource Database Texanna1 Excel Discussion (Misc queries) 1 September 12th 06 06:35 AM
Using Excel as a database and need macro or vba to take data entered on one tab and update the database by adding to the next avail row rjr Excel Programming 5 June 11th 06 09:43 PM
Excel error while trying to import data from an Access database - MSQRY32.exe has generated errors X_HOBBES Excel Discussion (Misc queries) 0 March 15th 05 06:46 PM


All times are GMT +1. The time now is 04:04 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"