Macro that worked stopped working

F

Freddy

I have the following that has worked for months and now has stopped? Is
there some limit? It basically takes a number (Fixed digits like 1234 + a
calculated part) and pastes it into a cell.

Sheets("Serial Number Log").Select
Range("A1").End(xlDown).Offset(1, 0).Select
Sheets("DO NOT DELETE").Select
Range("G54").Select
Selection.Copy
Sheets("Serial Number Log").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(0, 23).Copy
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Work Order Form").Select
Range("H25").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
 
D

Dave Peterson

I'm not sure why it stopped??

But I think that this does the same thing.

Dim NextCell as range

with worksheets("serial number log")
set nextcell = .range("A1").end(xldown).offset(1,0)
end with
nextcell.value = worksheets("do not delete").range("g54").value

worksheets("work order form").range("H25").value = nextcell.offset(0,23).value
 
B

Barb Reinhardt

Try this. Keep in mind it has no error checking in it if the worksheets
don't exist.

Option Explicit
Sub Test()
Dim myWB As Excel.Workbook
Dim myWS As Excel.Worksheet
Dim mySourceWS As Excel.Worksheet
Dim myRange As Excel.Range

Set myWB = ThisWorkbook
Set myWS = myWB.Sheets("Serial Number Log")
Set myRange = myWS.Cells(1, 1).End(xlDown).Offset(1, 0)

Set mySourceWS = myWB.Sheets("DO NOT DELETE")
mySourceWS.Range("G54").Copy

myRange.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False

myRange.Offset(0, 23).Copy
With myWB.Sheets("Work Order Form").Range("H25")
.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
End With

End Sub

Untested!

HTH,
Barb Reinhardt
 

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

Top