Simple line fix request.

  • Thread starter Thread starter sungen99
  • Start date Start date
S

sungen99

As I am only a hack when it comes to programming I need a little hel
with something that I’m sure is really easy.

I kinda have a program that records data for a day and then at the en
of the day adds it to the end of another spreadsheet that keep all th
records.

I wanted to merger the file so it is all in one spreadsheet. The cod
below is what the data file is but I don’t know how to change the lik
to make it just reflect the “trade history” worksheet now instead o
this other file.

Sorry for being so stupid.


Set destWB = Workbooks.Open("C:\Documents and Settings\Da
Smith\Taris\Admin\Execution\Taris 2005 Data-Ver1 1.xls"
 
Assume DestWb is dimmed as Workbook. If so, you can't just redim it to be a
worksheet and point it at a worksheet without adjusting all code that used
it to expect a worksheet.

Dim DestWb as Worksheet
set DestWb = Worksheets("Trade History")

but you would need to make other adjustments
 
This is my code that does this. does this help you more?


Sub copy_to_another_workbook()

Dim sourceRange As Range
Dim destrange As Range
Dim destWB As Workbook
Dim Lr As Long

Application.ScreenUpdating = False


Set destWB = Workbooks.Open("C:\Data-Ver1 1.xls")

Lr = LastRow(destWB.Worksheets("At A Glance")) + 1
Set sourceRange =
ThisWorkbook.Worksheets("Today").Range("A2:N500")
Set destrange = destWB.Worksheets("At A Glance").Range("A" & Lr)
sourceRange.Copy
destrange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
destWB.Close True
 
Dim destWS as Worksheet
Set destWS = ThisWorkbook.Worksheets("Trade History")

Lr = LastRow(destWS) + 1
Set sourceRange =
ThisWorkbook.Worksheets("Today").Range("A2:N500")
Set destrange = destWS.Range("A" & Lr)
sourceRange.Copy
destrange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top