#1   Report Post  
MWH
 
Posts: n/a
Default Copy Code Needed

I'm exporting data from Access to Excel
On one worksheet I will have the data from my database
I need to copy that data to a column on another worksheet in the workbook
I will be tracking the data daily, so I need it to copy the data to a new
column every day (with a date stamp) so I can compare the changes.

Any help is appreciated!


--
Mark W. Hanford



  #2   Report Post  
JMB
 
Posts: n/a
Default

Here is one possibility. This copies Column A from Sheet2 to the next
available column in Row1 of Sheet3 (inserting the date in the first row and
the data in the second+ rows).

You will need to change the copy from/to sheets as well as the copy from
column and the copy to row numbers if they are different.

Sub CopyColumn()
Dim SourceWkSht As Worksheet
Const SourceFirstRow As Long = 1
Dim SourceLastRow As Long
Const SourceCol As Integer = 1
Dim DestWkSht As Worksheet
Const DestRow As Long = 1
Dim DestCol As Integer

Set SourceWkSht = Sheet2
Set DestWkSht = Sheet3
SourceLastRow = SourceWkSht.Cells(Rows.Count, 1).End(xlUp).Row

If IsEmpty(DestWkSht.UsedRange) Then
DestCol = 1
Else: DestCol = DestWkSht.Cells(DestRow,
Columns.Count).End(xlToLeft).Column + 1
End If

DestWkSht.Cells(DestRow, DestCol) = Date
SourceWkSht.Range(SourceWkSht.Cells(SourceFirstRow , SourceCol), _
SourceWkSht.Cells(SourceLastRow, SourceCol)).Copy _
DestWkSht.Cells(DestRow + 1, DestCol)

End Sub


The "Else" statement is supposed to all be on one line. The post will
likely wrap it to a second line, so you will have to fix.


"MWH" wrote:

I'm exporting data from Access to Excel
On one worksheet I will have the data from my database
I need to copy that data to a column on another worksheet in the workbook
I will be tracking the data daily, so I need it to copy the data to a new
column every day (with a date stamp) so I can compare the changes.

Any help is appreciated!


--
Mark W. Hanford




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
reminder notifications in a column L Mieth Excel Discussion (Misc queries) 6 June 10th 05 11:00 AM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM
formula / code help needed Paul Watkins Excel Discussion (Misc queries) 2 March 16th 05 08:27 PM
Help with COPY code JVLin Excel Discussion (Misc queries) 0 March 6th 05 03:33 PM
code to Copy cells from the above row. Fernando Excel Worksheet Functions 1 January 27th 05 08:14 PM


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