PC Review


Reply
Thread Tools Rate Thread

Create Named Ranges (Headers) - then using range name in formula

 
 
ManhattanRebel
Guest
Posts: n/a
 
      1st Aug 2008

In a macro, I am selecting ten columns and creating range names based on the
top row.

Then I cut cells from another column and paste it to the appropriate column
by range name.

For example, I find the word "red" in cell D95. I want to paste that word,
and the cell next to it, in the column with the range name "red" in the same
row, 95. (I just want to move it over so it's in the column with the same
name.)

If I use the following code, I get an error:
Range(Cells(i, "CC"), Cells(i, "CD")).Cut Destination:=Cells(i, "Red")

Is there a way for me to specify that "Red" is only the column part of the
cell address?

Thank you.
 
Reply With Quote
 
 
 
 
Dick Kusleika
Guest
Posts: n/a
 
      1st Aug 2008
On Fri, 1 Aug 2008 10:47:00 -0700, ManhattanRebel
<(E-Mail Removed)> wrote:

>
>In a macro, I am selecting ten columns and creating range names based on the
>top row.
>
>Then I cut cells from another column and paste it to the appropriate column
>by range name.
>
>For example, I find the word "red" in cell D95. I want to paste that word,
>and the cell next to it, in the column with the range name "red" in the same
>row, 95. (I just want to move it over so it's in the column with the same
>name.)
>
>If I use the following code, I get an error:
>Range(Cells(i, "CC"), Cells(i, "CD")).Cut Destination:=Cells(i, "Red")
>
>Is there a way for me to specify that "Red" is only the column part of the
>cell address?
>


Cells(i, "CC").Resize(,2).Cut Destination:=Intersect(Rows(i),
Range("Red").EntireColumn)
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com
 
Reply With Quote
 
ManhattanRebel
Guest
Posts: n/a
 
      1st Aug 2008
Thank you, Dick.

I think that will work fine, but I am getting a compile error "Expected:
list separator or )" The only thing I am doing different is that my range
name is not just one word. It is actually "Red One". It has a space in it.
I don't know if that messes up anything, but I suspect not.

Am I missing a ) or : somewhere?
Thx again.

"Dick Kusleika" wrote:

> On Fri, 1 Aug 2008 10:47:00 -0700, ManhattanRebel
> <(E-Mail Removed)> wrote:
>
> >
> >In a macro, I am selecting ten columns and creating range names based on the
> >top row.
> >
> >Then I cut cells from another column and paste it to the appropriate column
> >by range name.
> >
> >For example, I find the word "red" in cell D95. I want to paste that word,
> >and the cell next to it, in the column with the range name "red" in the same
> >row, 95. (I just want to move it over so it's in the column with the same
> >name.)
> >
> >If I use the following code, I get an error:
> >Range(Cells(i, "CC"), Cells(i, "CD")).Cut Destination:=Cells(i, "Red")
> >
> >Is there a way for me to specify that "Red" is only the column part of the
> >cell address?
> >

>
> Cells(i, "CC").Resize(,2).Cut Destination:=Intersect(Rows(i),
> Range("Red").EntireColumn)
> --
> Dick Kusleika
> Microsoft MVP-Excel
> http://www.dailydoseofexcel.com
>

 
Reply With Quote
 
ManhattanRebel
Guest
Posts: n/a
 
      1st Aug 2008
No worry. I think I have it now. A comma needed to be inserted after
Range(Cells(i,"CC")
One comma was not enough.
Thanks again.


"ManhattanRebel" wrote:

> Thank you, Dick.
>
> I think that will work fine, but I am getting a compile error "Expected:
> list separator or )" The only thing I am doing different is that my range
> name is not just one word. It is actually "Red One". It has a space in it.
> I don't know if that messes up anything, but I suspect not.
>
> Am I missing a ) or : somewhere?
> Thx again.
>
> "Dick Kusleika" wrote:
>
> > On Fri, 1 Aug 2008 10:47:00 -0700, ManhattanRebel
> > <(E-Mail Removed)> wrote:
> >
> > >
> > >In a macro, I am selecting ten columns and creating range names based on the
> > >top row.
> > >
> > >Then I cut cells from another column and paste it to the appropriate column
> > >by range name.
> > >
> > >For example, I find the word "red" in cell D95. I want to paste that word,
> > >and the cell next to it, in the column with the range name "red" in the same
> > >row, 95. (I just want to move it over so it's in the column with the same
> > >name.)
> > >
> > >If I use the following code, I get an error:
> > >Range(Cells(i, "CC"), Cells(i, "CD")).Cut Destination:=Cells(i, "Red")
> > >
> > >Is there a way for me to specify that "Red" is only the column part of the
> > >cell address?
> > >

> >
> > Cells(i, "CC").Resize(,2).Cut Destination:=Intersect(Rows(i),
> > Range("Red").EntireColumn)
> > --
> > Dick Kusleika
> > Microsoft MVP-Excel
> > http://www.dailydoseofexcel.com
> >

 
Reply With Quote
 
ManhattanRebel
Guest
Posts: n/a
 
      2nd Aug 2008
I am getting a "Range of Object'_Global' error 1004 when I use this formula:
Range(Cells(i, "CC")).Resize(, 2).Cut Destination:=Intersect(Rows(i),
Range("Red One").EntireColumn)

Do I have to specify which worksheet I'm using for the destination? The
sheet is "Color". Where and how should I specify that, if necessary?
Thx.



"ManhattanRebel" wrote:

> No worry. I think I have it now. A comma needed to be inserted after
> Range(Cells(i,"CC")
> One comma was not enough.
> Thanks again.
>
>
> "ManhattanRebel" wrote:
>
> > Thank you, Dick.
> >
> > I think that will work fine, but I am getting a compile error "Expected:
> > list separator or )" The only thing I am doing different is that my range
> > name is not just one word. It is actually "Red One". It has a space in it.
> > I don't know if that messes up anything, but I suspect not.
> >
> > Am I missing a ) or : somewhere?
> > Thx again.
> >
> > "Dick Kusleika" wrote:
> >
> > > On Fri, 1 Aug 2008 10:47:00 -0700, ManhattanRebel
> > > <(E-Mail Removed)> wrote:
> > >
> > > >
> > > >In a macro, I am selecting ten columns and creating range names based on the
> > > >top row.
> > > >
> > > >Then I cut cells from another column and paste it to the appropriate column
> > > >by range name.
> > > >
> > > >For example, I find the word "red" in cell D95. I want to paste that word,
> > > >and the cell next to it, in the column with the range name "red" in the same
> > > >row, 95. (I just want to move it over so it's in the column with the same
> > > >name.)
> > > >
> > > >If I use the following code, I get an error:
> > > >Range(Cells(i, "CC"), Cells(i, "CD")).Cut Destination:=Cells(i, "Red")
> > > >
> > > >Is there a way for me to specify that "Red" is only the column part of the
> > > >cell address?
> > > >
> > >
> > > Cells(i, "CC").Resize(,2).Cut Destination:=Intersect(Rows(i),
> > > Range("Red").EntireColumn)
> > > --
> > > Dick Kusleika
> > > Microsoft MVP-Excel
> > > http://www.dailydoseofexcel.com
> > >

 
Reply With Quote
 
Dick Kusleika
Guest
Posts: n/a
 
      2nd Aug 2008
On Fri, 1 Aug 2008 13:44:03 -0700, ManhattanRebel
<(E-Mail Removed)> wrote:

>Thank you, Dick.
>
>I think that will work fine, but I am getting a compile error "Expected:
>list separator or )" The only thing I am doing different is that my range
>name is not just one word. It is actually "Red One". It has a space in it.
>I don't know if that messes up anything, but I suspect not.
>
>Am I missing a ) or : somewhere?
>Thx again.
>
>>
>> Cells(i, "CC").Resize(,2).Cut Destination:=Intersect(Rows(i),
>> Range("Red").EntireColumn)


'Red One' should not be a problem. Note that the code wraps in most
newsreaders. Make sure that's all one line.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com
 
Reply With Quote
 
Dick Kusleika
Guest
Posts: n/a
 
      2nd Aug 2008
On Fri, 1 Aug 2008 16:09:01 -0700, ManhattanRebel
<(E-Mail Removed)> wrote:

>I am getting a "Range of Object'_Global' error 1004 when I use this formula:
>Range(Cells(i, "CC")).Resize(, 2).Cut Destination:=Intersect(Rows(i),
>Range("Red One").EntireColumn)
>
>Do I have to specify which worksheet I'm using for the destination? The
>sheet is "Color". Where and how should I specify that, if necessary?
>Thx.
>


You don't *have* to, but you should. If you don't, it assumes the active
sheet. I assumed both the copied cells and the destination are on the same
sheet.

Dim sh As Worksheet

Set sh = ThisWorkbook.Sheets("Color")

sh.Cells(i,"CC").Resize(,2).Cut Intersect(sh.Rows(i), sh.Range("Red
One").EntireColumn)

Make sure that last bit is all on one line.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com
 
Reply With Quote
 
ManhattanRebel
Guest
Posts: n/a
 
      2nd Aug 2008
Everything is on the same worksheet. Still get the Method 'Range of Object'
_Global' failed error, even after doing what you suggested. Don't know
what's going on.


"Dick Kusleika" wrote:

> On Fri, 1 Aug 2008 16:09:01 -0700, ManhattanRebel
> <(E-Mail Removed)> wrote:
>
> >I am getting a "Range of Object'_Global' error 1004 when I use this formula:
> >Range(Cells(i, "CC")).Resize(, 2).Cut Destination:=Intersect(Rows(i),
> >Range("Red One").EntireColumn)
> >
> >Do I have to specify which worksheet I'm using for the destination? The
> >sheet is "Color". Where and how should I specify that, if necessary?
> >Thx.
> >

>
> You don't *have* to, but you should. If you don't, it assumes the active
> sheet. I assumed both the copied cells and the destination are on the same
> sheet.
>
> Dim sh As Worksheet
>
> Set sh = ThisWorkbook.Sheets("Color")
>
> sh.Cells(i,"CC").Resize(,2).Cut Intersect(sh.Rows(i), sh.Range("Red
> One").EntireColumn)
>
> Make sure that last bit is all on one line.
> --
> Dick Kusleika
> Microsoft MVP-Excel
> http://www.dailydoseofexcel.com
>

 
Reply With Quote
 
ManhattanRebel
Guest
Posts: n/a
 
      2nd Aug 2008
Excuse me. Now I'm getting the error, but instead of Global', I get
Worksheet'.

"Dick Kusleika" wrote:

> On Fri, 1 Aug 2008 13:44:03 -0700, ManhattanRebel
> <(E-Mail Removed)> wrote:
>
> >Thank you, Dick.
> >
> >I think that will work fine, but I am getting a compile error "Expected:
> >list separator or )" The only thing I am doing different is that my range
> >name is not just one word. It is actually "Red One". It has a space in it.
> >I don't know if that messes up anything, but I suspect not.
> >
> >Am I missing a ) or : somewhere?
> >Thx again.
> >
> >>
> >> Cells(i, "CC").Resize(,2).Cut Destination:=Intersect(Rows(i),
> >> Range("Red").EntireColumn)

>
> 'Red One' should not be a problem. Note that the code wraps in most
> newsreaders. Make sure that's all one line.
> --
> Dick Kusleika
> Microsoft MVP-Excel
> http://www.dailydoseofexcel.com
>

 
Reply With Quote
 
ManhattanRebel
Guest
Posts: n/a
 
      2nd Aug 2008
This is the code that creates name ranges from the headings:
Columns("CW:CW").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.CreateNames Top:=True, Left:=False, Bottom:=False, Right:= _
False
Range("CE5").Select


"Dick Kusleika" wrote:

> On Fri, 1 Aug 2008 13:44:03 -0700, ManhattanRebel
> <(E-Mail Removed)> wrote:
>
> >Thank you, Dick.
> >
> >I think that will work fine, but I am getting a compile error "Expected:
> >list separator or )" The only thing I am doing different is that my range
> >name is not just one word. It is actually "Red One". It has a space in it.
> >I don't know if that messes up anything, but I suspect not.
> >
> >Am I missing a ) or : somewhere?
> >Thx again.
> >
> >>
> >> Cells(i, "CC").Resize(,2).Cut Destination:=Intersect(Rows(i),
> >> Range("Red").EntireColumn)

>
> 'Red One' should not be a problem. Note that the code wraps in most
> newsreaders. Make sure that's all one line.
> --
> Dick Kusleika
> Microsoft MVP-Excel
> http://www.dailydoseofexcel.com
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create named ranges WITHOUT using the Names Cells or Range Fernando Fernandes Microsoft Excel Programming 16 28th Apr 2009 07:14 AM
Using a formula to create named range reference rgb65@bellsouth.net Microsoft Excel Worksheet Functions 4 29th Jun 2005 08:03 PM
How Do You Call Several Named Ranges From A Named Range Minitman Microsoft Excel Misc 13 24th Mar 2004 11:18 PM
How Do You Call Several Named Ranges From A Named Range Minitman Microsoft Excel Worksheet Functions 14 24th Mar 2004 11:18 PM
How Do You Call Several Named Ranges From A Named Range Minitman Microsoft Excel Programming 13 24th Mar 2004 11:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:05 AM.