Range references in VB

G

Guest

I am trying to loop through rows and paste data on each row. I keep getting
an error code on this (even though it should be VERY simple)!

j=1
Sheets("Array 1").Range("A75:ES75").Copy
Sheets(Cbo_Product & "_BidformPage1").Select
Range("A" & j).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


blah blah blah. I get the error on the Range("A" & j).select line.
 
G

Guest

dim sh as Worksheet
On Error resume Next
set sh = Sheets(Cbo_Product & "_BidformPage1")
On error goto 0
if not sh is nothing then
j=1
Sheets("Array 1").Range("A75:ES75").Copy
sh.Range("A" & j).PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
else
Msgbox "Sheet not found"
End if
 
N

Nigel

Assuming that the value of j does not overflow then the statement is
correct.
But you cannot select a cell if the sheet is protected.

You could try....
Range("A" & j)..PasteSpecial Paste:=xlPasteValues

to avoid the selects.
 

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