ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Code needed (https://www.excelbanter.com/excel-programming/332484-copy-code-needed.html)

MWH

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




JPW

Copy Code needed
 
That's fairly easy. What's the "from" range and what's the "to" range?

"MWH" wrote in message ...
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





Roman[_4_]

Copy Code needed
 
This could help you:
-----------------------------

Sub copyit()
Application.ScreenUpdating = False
Dim rfoundempty As Range
Dim inow As String
Dim tgt, src As Worksheet
Dim x As Integer
Set src = Workbooks("sourcebookname").Worksheets("sourceshee tname")
Set tgt = Workbooks("targetbookname").Worksheets("targetshee tname")
src.Columns(1).Select
Selection.Copy
tgt.Activate
x = Application.WorksheetFunction.CountA(src.Range("1: 1")) + 1
Do Until Application.WorksheetFunction.CountA(tgt.Columns(x )) = 0
x = x + 1
Loop
tgt.Activate
tgt.Columns(x).Select
activesheet.Paste
Cells(1, x).AddComment
Cells(1, x).Comment.Visible = False
Cells(1, x).Comment.Text Text:="imported:" & Chr(10) & Now()
Application.ScreenUpdating = False
End Sub


JPW

Copy Code needed
 
Be careful, this will overwrite your data every time you run it, and uses this clipboard (and is therefore interruptable by other
Windows operations).

"Roman" wrote in message oups.com...
This could help you:
-----------------------------

Sub copyit()
Application.ScreenUpdating = False
Dim rfoundempty As Range
Dim inow As String
Dim tgt, src As Worksheet
Dim x As Integer
Set src = Workbooks("sourcebookname").Worksheets("sourceshee tname")
Set tgt = Workbooks("targetbookname").Worksheets("targetshee tname")
src.Columns(1).Select
Selection.Copy
tgt.Activate
x = Application.WorksheetFunction.CountA(src.Range("1: 1")) + 1
Do Until Application.WorksheetFunction.CountA(tgt.Columns(x )) = 0
x = x + 1
Loop
tgt.Activate
tgt.Columns(x).Select
activesheet.Paste
Cells(1, x).AddComment
Cells(1, x).Comment.Visible = False
Cells(1, x).Comment.Text Text:="imported:" & Chr(10) & Now()
Application.ScreenUpdating = False
End Sub




MWH

Copy Code needed
 
Range("A2:A56") to the same rows different columns on another worksheet,
Also I would like a date stamp =TODAY() to be in A1


"JPW" wrote in message
...
That's fairly easy. What's the "from" range and what's the "to" range?

"MWH" wrote in message
...
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







Roman[_4_]

Copy Code needed
 
This won't overwrite the data. It's finding an empty column on the
target sheet and paste the data into it.


MWH

Copy Code needed
 
Code halts at "src.Columns(1).Select"
Any suggestions?

"Roman" wrote in message
oups.com...
This won't overwrite the data. It's finding an empty column on the
target sheet and paste the data into it.




Roman[_4_]

Copy Code needed
 
It works OK for me.
I guess there could be a problem in sourcebookname, sourcesheetname...
definitions.
They should look like:

Set src = Workbooks("book1").Wo*rksheets("sheet1") ' that is your
source book and sheet
Set tgt = Workbooks("book2").Wo*rksheets("sheet2") 'that is your
target book and sheet

Well I´m not VB proffesional in anyway, so please take the code as a
discussion or study material rather than a bussiness solution.

Keep learning.



All times are GMT +1. The time now is 11:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com