![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 6
|
Right, this is my problem:
At the moment I'm getting a variety of errors generally when it comes to the pasting stage, and can't get my head around the problem. Any suggestions? For the record, am using Excel 97 SR2 (can't upgrade - work system) and this is my code so far: ******************************************** Private Sub CommandButton1_Click() 'Prepare Excel: Application.EnableEvents = False Application.DisplayAlerts = False Application.ScreenUpdating = False 'Open fault sheet Workbooks.Open FileName:="W:Monthly Fault SheetFault Sheet (MAY onwards) 2002.xls" Workbooks.Open FileName:="W:Monthly Fault SheetDaily Fault Handoff.xls" ' ***** GENERAL NETWORK ***** Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Range("A4:H100").ClearContents For GenNet = 4 To 100 If Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Cells(GenNet, 6) = "" Then GoTo GenNetSkip If Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Cells(GenNet, 5) = "" Then Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Range.Cells(GenNet, 1).Cells(GenNet, 8).Copy For GenNet2 = 4 To 100 If Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Cells(GenNet2, 1) = "" Then GoTo GenNetPaster Next GenNet2 GoTo GenNetSkip GenNetPaster: Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Range("A" & GenNet2, "H" & GenNet2).Select Selection.PasteSpecial (x1PasteAll) GenNetSkip: Next GenNet 'Re-set Excel Application.EnableEvents = True Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub [ This Message was edited by: Juggernaut on 2002-05-23 02:00 ] |
|
|
|
|
|
#2 |
|
New Member
Join Date: May 2002
Posts: 6
|
Ok, I've got a little further now - I can see where it's going wrong. Basically it's not getting the information into the clipboard properly, so when it comes to paste it has nothing to paste.
If you already have something in the clipboard, it pastes that. The code is now: ********************************************* Private Sub CommandButton1_Click() 'Prepare Excel: Application.EnableEvents = False Application.DisplayAlerts = False Application.ScreenUpdating = False 'Open fault sheet Workbooks.Open FileName:="W:Monthly Fault SheetFault Sheet (MAY onwards) 2002.xls" Workbooks.Open FileName:="W:Monthly Fault SheetDaily Fault Handoff.xls" ' ***** GENERAL NETWORK ***** Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Range("A4:H100").ClearContents For GenNet = 4 To 100 Workbooks("Fault Sheet (MAY onwards) 2002.xls").Activate If Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Cells(GenNet, 6) = "" Then GoTo GenNetSkip If Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Cells(GenNet, 5) = "" Then Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Range("A" & GenNet, "H" & GenNet).Select Selection.Copy For GenNet2 = 4 To 100 If Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Cells(GenNet2, 1) = "" Then GoTo GenNetPaster Next GenNet2 GoTo GenNetSkip GenNetPaster: Workbooks("Daily Fault Handoff.xls").Activate Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Cells(GenNet, 2).Select Selection.PasteSpecial (x1PasteAll) GenNetSkip: Next GenNet Workbooks("Daily Fault Handoff.xls").Activate 'Re-set Excel Application.EnableEvents = True Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub ********************************************* Where am I going wrong?! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|