Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
MJS MJS is offline
external usenet poster
 
Posts: 16
Default Copying Form cells (WS1) to Database (WS2)

I need a macro to copy cells from a form created in Excel 2003 (Worksheet 1)
to a database (Worksheet 2). There is no structured range of data in the
form, however i need it summarised on 1 row in Worksheet 2.

I have recored a macro to export the data from WS1 to WS2 however i know
this is going to overwrite the previous run. Therefore everytime the macro is
run i need it to fill on the row below or next available row.

Hope someone can help. Thanks

Current Macro below,

Sub Info_Copy()
'
' Info_Copy Macro
' Macro recorded 12/03/2009 by ...
'

'
Range("G3:N3").Select
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("C4:J4").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("Y3:AF3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("K4:R4").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("G5:AF5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("S4:AR4").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
ActiveWindow.SmallScroll Down:=21
Range("Z48").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("AS4").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("Z50").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("AT4").Select
ActiveSheet.Paste
Range("AS4").Select
Sheets("Sheet1").Select
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Copying Form cells (WS1) to Database (WS2)

I'm not sure I understand completely, but maybe...

Sub Info_Copy()

Dim fWks as worksheet 'from worksheet
dim tWks as worksheet 'to worksheet
Dim DestCell as range

set fwks = worksheets("sheet1")
set twks = worksheets("sheet1 (2)")

with twks
'destination is under the last used cell in column A
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

with twks
destcell.value = .range("AS40").value
'next cell to the right
destcell.offset(0,1).value = .range("x99").value
'column C
destcell.offset(0,2).value = .range("g1234").value
'and so forth
end with
End Sub

It does rely on column A always having data in it when the row is used.

MJS wrote:

I need a macro to copy cells from a form created in Excel 2003 (Worksheet 1)
to a database (Worksheet 2). There is no structured range of data in the
form, however i need it summarised on 1 row in Worksheet 2.

I have recored a macro to export the data from WS1 to WS2 however i know
this is going to overwrite the previous run. Therefore everytime the macro is
run i need it to fill on the row below or next available row.

Hope someone can help. Thanks

Current Macro below,

Sub Info_Copy()
'
' Info_Copy Macro
' Macro recorded 12/03/2009 by ...
'

'
Range("G3:N3").Select
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("C4:J4").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("Y3:AF3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("K4:R4").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("G5:AF5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("S4:AR4").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
ActiveWindow.SmallScroll Down:=21
Range("Z48").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("AS4").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("Z50").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1 (2)").Select
Range("AT4").Select
ActiveSheet.Paste
Range("AS4").Select
Sheets("Sheet1").Select
End Sub



--

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
Help. Trying to use Word as a form with Excel as a database MiVidaLoca Excel Discussion (Misc queries) 0 June 9th 08 10:44 PM
rudimentary database form maybe? JethroUK© New Users to Excel 3 October 14th 07 09:06 AM
How can i create a form linked to a database Halladan Excel Discussion (Misc queries) 3 August 20th 07 08:12 AM
Macros VBA and Converting Form to Database IMS Lori Excel Discussion (Misc queries) 7 January 15th 07 06:19 PM
getting data from a database into a form Brendan Excel Worksheet Functions 2 October 8th 06 10:24 PM


All times are GMT +1. The time now is 05:59 PM.

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"