I am working on a piece of VBA code (Visual Basic 6.5) that will simply take a date (different every time) from a specified cell, convert it to a day and paste the result into the tab. This is repeated across six tabs.
I have finished the coding and it works perfectly on the original workbook but when I open another workbook and try to run the macro from the first I get an error that states
Run-time error '1004':
Method 'select' of object '_worksheet' failed
When I try and debug it the first line of coding is highlighted which simply says
Sheet1.Select
At this point I am tearing my hair out and can't figure out what is causing this. Could anyone point me in the right direction?
Its worth noting that I know that my code is far from being the most efficient VBA coding that I could have used... but its my first one so take it easy
Please see coding below
Sub Macro1()
'
' borc Macro
' multisheetdatetoday
'
'
Sheet1.Select
Range("A3").Select
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet1.Name = target
Sheet2.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet2.Name = target
Sheet3.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet3.Name = target
Sheet4.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet4.Name = target
Sheet5.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet5.Name = target
Sheet6.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet6.Name = target
MsgBox "Completely unnecessary message boxes are made of win!"
End Sub
Any help on this would be very much appreciated.
I have finished the coding and it works perfectly on the original workbook but when I open another workbook and try to run the macro from the first I get an error that states
Run-time error '1004':
Method 'select' of object '_worksheet' failed
When I try and debug it the first line of coding is highlighted which simply says
Sheet1.Select
At this point I am tearing my hair out and can't figure out what is causing this. Could anyone point me in the right direction?
Its worth noting that I know that my code is far from being the most efficient VBA coding that I could have used... but its my first one so take it easy
Please see coding below
Sub Macro1()
'
' borc Macro
' multisheetdatetoday
'
'
Sheet1.Select
Range("A3").Select
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet1.Name = target
Sheet2.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet2.Name = target
Sheet3.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet3.Name = target
Sheet4.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet4.Name = target
Sheet5.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet5.Name = target
Sheet6.Select
Range("A3").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(R[-1]C,""dddd"")"
Range("A3").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set target = Range("A1")
Sheet6.Name = target
MsgBox "Completely unnecessary message boxes are made of win!"
End Sub
Any help on this would be very much appreciated.