Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MWH MWH is offline
external usenet poster
 
Posts: 10
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  
Posted to microsoft.public.excel.programming
JPW JPW is offline
external usenet poster
 
Posts: 6
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
JPW JPW is offline
external usenet poster
 
Posts: 6
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
MWH MWH is offline
external usenet poster
 
Posts: 10
Default 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








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default 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.

  #7   Report Post  
Posted to microsoft.public.excel.programming
MWH MWH is offline
external usenet poster
 
Posts: 10
Default 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.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default 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.

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
VBA code needed ernie New Users to Excel 1 March 19th 10 12:45 PM
Copy Code Needed MWH Excel Worksheet Functions 1 June 22nd 05 06:49 AM
Code Needed Carolyn[_3_] Excel Programming 4 June 16th 04 01:26 PM
Better code needed ceplane Excel Programming 6 May 10th 04 07:59 PM
Fw:code needed ibo Excel Programming 2 August 5th 03 09:30 PM


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