Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Range references in VB

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Range references in VB


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

--
Regards,
Tom Ogilvy


"MathCzyk" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Range references in VB

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.

--
Cheers
Nigel



"MathCzyk" wrote in message
...
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making all references in a range absolute Kasper Excel Discussion (Misc queries) 1 March 9th 09 02:09 PM
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM
Arrays and range references in VBA Stewart Excel Programming 7 August 22nd 05 05:19 PM
Column and row references of range Michael Allen Excel Programming 1 July 6th 04 07:54 PM
Bracketed Range References Bob[_29_] Excel Programming 3 August 8th 03 04:50 PM


All times are GMT +1. The time now is 01:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"