
December 31st, 2003, 08:23 AM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
excel macro copy/paste to new sheet, next row
A little background, I've got an excel spreadsheet that gets updated everyday. If there are no problems at the facility, there is nothing to paste to the other worksheet. I just need to record problems at the facility on to another worksheet. I could do it by date, but I would have big blank areas on the sheet because we only have problems a couple times a month. This spreadsheet captures a years worth of operational data.
here's what I've got so far, it may not be pretty but it works (except for the part in bold that I need to paste to the next row)
Quote:
Msg = "Comments are necessary if there was Planned or Unplanned Downtime" ' Define message.
Style = vbOKCancel + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes' button.
MyString = "Yes" ' Perform some action.
Sheets("Time").Select
Range("l21:z21").Select
Selection.Copy
Range("l22").Select
Selection.Offset(Range("k21"), 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End If
Sheets("Sheet2").Select
Range("I13:K17").Select
If Range("J37") > "0" Then
Msg = "Do you wish to submit these downtime hours?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title)
Else: End If
If Response = vbYes Then ' User chose Yes' button.
MyString = "Yes" ' Perform some action.
Sheets("Sheet2").Select
Range("M13").Select
If Range("M13") = "" Then
Msg = "You must explain the reason for the downtime the Comments area!" ' Define message.
Style = vbOKCancel + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title)
Else: Sheets("Sheet2").Select
Range("M13").Select
Selection.Copy
Sheets("Results").Select
Range("B40").Select
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets("Sheet2").Select
Range("L2").Select
Selection.Copy
Sheets("Results").Select
Range("A40").Select
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, SkipBlanks:= _
False, Transpose:=False
Sheets("Sheet2").Select
If Response = vbOK Then ' User chose OK' button.
MyString = "Yes" ' Perform some action.
Sheets("Sheet2").Select
|
I need to start @ B40 and each time there is something in M13 (and sum J37 > 0) it needs to past to B41, then the next time B42.
I hope this makes sense!
thanks!
...Brady
|