Runtime error 1004 when selct a range

blaksnm

Well-known Member
Joined
Dec 15, 2009
Messages
554
Office Version
  1. 365
Platform
  1. Windows
My macro:
Sheets("Formulas").Range("FormulaTransit").Copy
Sheets("List").Select
Range("A1").Select
Set tbl = ActiveCell.CurrentRegion
tbl.Offset(tbl.Rows.Count, 0).Resize(1, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

fails in line "Range("A2").select": "Run Time error 1004

I want to paste the result of my formula as value in the bottom of the list in another sheet

Any clue how to make it work anyone?

Best regards Snoopy
 
That's odd as there is no selecting in the code I posted. Which line causes it?
Here the macro stops: tbl.Offset(tbl.Rows.Count, 0).Resize(1, 1).Select 'PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
That's odd as there is no selecting in the code I posted. Which line causes it?
tbl.Offset(tbl.Rows.Count, 0).Resize(1, 1).Select 'PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
 
Upvote 0
tbl.Offset(tbl.Rows.Count, 0).Resize(1, 1).Select 'PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
tbl.Offset(tbl.Rows.Count, 0).Resize(1, 1).Select 'PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Here is the essence of my macro:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
ActiveSheet.Unprotect 'DrawingObjects:=False, Contents:=True, Scenarios:=False, AllowFormattingColumns:=True, AllowFormattingRows:=True
Application.ScreenUpdating = False

' Bla bla bla - does some stuff

If Not Intersect(Target, Range("K" & Rw)) Is Nothing Then
Cancel = True

Sheets("Formula").Range("Transit").Copy'(=range("a5:R5") in sheet("Formula")
Set tbl = Sheets("List").Range("A1").CurrentRegion
tbl.Offset(tbl.Rows.Count, 0).Resize(1, 1).Select 'PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If

Application.ScreenUpdating = True
'ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False, AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowInsertingHyperlinks:=True


'Does some more stuff
End Sub

My aim is to copy at formula-set an paste the values in the bottom og a list (in sheet("List)

Br Snoopy
 
Upvote 0
Why did you put Select there instead of the pastespecial?
 
Upvote 0
Why did you put Select there instead of the pastespecial?
I did it due not to damish anything (as a test) - if select worked out - thren I would change to paste
 
Upvote 0
Unfortunately all that did was reintroduce essentially the same problem we were trying to fix - namely that you can't select a range on a non-active sheet.
 
Upvote 0
Unfortunately all that did was reintroduce essentially the same problem we were trying to fix - namely that you can't select a range on a non-active sheet.
Thanks
Ill look into this advice :)
Br S
 
Upvote 0

Forum statistics

Threads
1,215,772
Messages
6,126,806
Members
449,337
Latest member
BBV123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top