MitzDriver
Board Regular
- Joined
- Aug 23, 2010
- Messages
- 60
For the most part all this works. However the third "withthisworkbook" section. it does not work at all.
Suggestions for changes will be very appreciated.
Suggestions for changes will be very appreciated.
Code:
Private Sub CommandButton1_Click()
'Copy "Balance Forward" to workbook DataFile.xls
Dim TargetWB As String
Dim ThisPath As String
Dim wkbDst As Workbook
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
On Error Resume Next
Set wkbDst = Workbooks("DataFile.xls")
If Err.Number Then Set wkbDst = Workbooks.Open("C:\Bingo Files\DataFile.xls")
On Error GoTo 0
[COLOR=lime]' this part works[/COLOR]
With ThisWorkbook.Worksheets("103").Range("P68:P70")
wkbDst.Worksheets("Sheet1").Range("A1").Resize(.Rows.Count, .Columns.Count).Value = .Value
End With
[COLOR=lime]' this part works[/COLOR]
With ThisWorkbook.Worksheets("104-A").Range("E26")
wkbDst.Worksheets("Sheet1").Range("B" & Lr + 1).Resize(.Rows.Count, .Columns.Count).Value = .Value
End With
[COLOR=red]' this part DOES NOT WORK[/COLOR]
With ThisWorkbook.Worksheets("104-D").Range("K12")
wkbDst.Worksheets("Sheet1").Range("C" & Lr + 1).Resize(.Rows.Count, .Columns.Count).Value = .Value
End With
wkbDst.Close SaveChanges:=True