Please help with selecting a range

K

keri

Hi,

I have this code;

Sub dump()

Sheets("raw1").Select
Range("car1").Select
Selection.Copy
Sheets("car1").Select
Range("a1").Select
Selection.Paste
End Sub

All I am looking to do is to select a named range and copy and paste to
another sheet. However on the Range("car1").Select line i get an
error;

Run time error 1004, Application defined or object defined error

I originally thought this would be a problem with the name of the
range, but I have tried naming a single cell as a range "pink" for
example! and it still doesn't work.

Any clues?

Thanks in advance.
 
B

Bill Kuunders

to select a named range I have used
application.goto reference:="car1"
selection.copy

greetings from New zealand
 
K

keri

Thanks! (Did you watch NewZealand win the motor racing this weekend?)

I now want to do an action for only odd numbered integer. So where my
code would normally say;

Dim i as integer
For i = 1 to 20

I only want it to apply to 1,3,5,7 etc

Is this possible?
 
B

Bob Phillips

Have you created an Excel Defined Names for car1?

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
D

Don Guillett

You didn't name a sheet and a range with the same name, did you?

Sub copynamed()'copy from named rgn to named rng
Range("car1").Copy Range("car2")
End Sub
 
D

Don Guillett

As a ex open wheel road racer who likes to watch A1 racing when Speed shows
it,
For i = 1 to 20 step 2
 
K

keri

My other half is data engineer for the NZ team! I had a wicked weekend
celebrating for them!

Thanks for the integer answer.

Anyway, no I realised my mistake with the sheet names and changed them.

What is an Excel Defined Name?

(In case you're wondering i've learnt basic VBA in Access but never
used Excel before....it's certainly interesting trying to make Access
knowledge work on this).
 
D

Don Guillett

A couple of ways
1. Select a range>insert>name>define>name it
1.a define it in the formula is box
2. select a range>type in a name in the NAME box next to the formula box
 

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