PC Review


Reply
Thread Tools Rate Thread

Column letter reference as number reference

 
 
=?Utf-8?B?bWNwaGM=?=
Guest
Posts: n/a
 
      30th Jan 2007
I use the below to get the vertical edge of the print area.

Range("Print_Area").Address

The output of this is something like "$A$:1$AZ$57".

I would like to run a macro that checks each cell in a row from column "A"
to (as in the above) column "AZ"

I would like to use something like

For col = 1 to 52

How do you represent AZ as 52? Or is there a better way of doing this? (I'm
sure there is)
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      30th Jan 2007
The code below will cycle through all the cells in the range you have
described and you can put your code in the middle. AZ equates to 52.

Sub checkcells()
For y = 1 To 57
For x = 1 To 52
check what you want to check for here
Next
Next
End Sub

"mcphc" wrote:

> I use the below to get the vertical edge of the print area.
>
> Range("Print_Area").Address
>
> The output of this is something like "$A$:1$AZ$57".
>
> I would like to run a macro that checks each cell in a row from column "A"
> to (as in the above) column "AZ"
>
> I would like to use something like
>
> For col = 1 to 52
>
> How do you represent AZ as 52? Or is there a better way of doing this? (I'm
> sure there is)

 
Reply With Quote
 
Niek Otten
Guest
Posts: n/a
 
      30th Jan 2007
Something like:

Sub test()
Dim a
For Each a In Range("print_Area")
MsgBox a
Next
End Sub

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"mcphc" <(E-Mail Removed)> wrote in message news:3127A9DD-E2F5-4B80-9ADC-(E-Mail Removed)...
|I use the below to get the vertical edge of the print area.
|
| Range("Print_Area").Address
|
| The output of this is something like "$A$:1$AZ$57".
|
| I would like to run a macro that checks each cell in a row from column "A"
| to (as in the above) column "AZ"
|
| I would like to use something like
|
| For col = 1 to 52
|
| How do you represent AZ as 52? Or is there a better way of doing this? (I'm
| sure there is)


 
Reply With Quote
 
Jason Lepack
Guest
Posts: n/a
 
      30th Jan 2007
public sub mcphc()
dim r as integer, c as integer
' rows 1 to 57
for r = 1 to 57
' columns A to AZ
for c = 1 to 52
' Print value of cell in immediate window
debug.print cells(r,c)
next c
next r
end sub

Cheers,
Jason Lepack

On Jan 30, 7:08 am, mcphc <m...@discussions.microsoft.com> wrote:
> I use the below to get the vertical edge of the print area.
>
> Range("Print_Area").Address
>
> The output of this is something like "$A$:1$AZ$57".
>
> I would like to run a macro that checks each cell in a row from column "A"
> to (as in the above) column "AZ"
>
> I would like to use something like
>
> For col = 1 to 52
>
> How do you represent AZ as 52? Or is there a better way of doing this? (I'm
> sure there is)


 
Reply With Quote
 
=?Utf-8?B?bWNwaGM=?=
Guest
Posts: n/a
 
      30th Jan 2007
Thanks for the help guys but not quiet what I was looking for.

The problem is the print area is always different so it could be

For col= 1 to 52

or

For col = 1 to 30

I need something like

For col= 1 to PrintAreaEdge

where PrintAreaEdge is the last vertical column number (ie 52 not letter
"AZ") in the print area.

Using the below

For Each a In Range("print_Area")
MsgBox a
Next

is close but I actually only want to search a few columns within the print
area
ie

For col = 1 to PrintAreaEdge - 5

Thanks

"Jason Lepack" wrote:

> public sub mcphc()
> dim r as integer, c as integer
> ' rows 1 to 57
> for r = 1 to 57
> ' columns A to AZ
> for c = 1 to 52
> ' Print value of cell in immediate window
> debug.print cells(r,c)
> next c
> next r
> end sub
>
> Cheers,
> Jason Lepack
>
> On Jan 30, 7:08 am, mcphc <m...@discussions.microsoft.com> wrote:
> > I use the below to get the vertical edge of the print area.
> >
> > Range("Print_Area").Address
> >
> > The output of this is something like "$A$:1$AZ$57".
> >
> > I would like to run a macro that checks each cell in a row from column "A"
> > to (as in the above) column "AZ"
> >
> > I would like to use something like
> >
> > For col = 1 to 52
> >
> > How do you represent AZ as 52? Or is there a better way of doing this? (I'm
> > sure there is)

>
>

 
Reply With Quote
 
Jason Lepack
Guest
Posts: n/a
 
      30th Jan 2007
for col = 1 to range("print_area").column

On Jan 30, 8:23 am, mcphc <m...@discussions.microsoft.com> wrote:
> Thanks for the help guys but not quiet what I was looking for.
>
> The problem is the print area is always different so it could be
>
> For col= 1 to 52
>
> or
>
> For col = 1 to 30
>
> I need something like
>
> For col= 1 to PrintAreaEdge
>
> where PrintAreaEdge is the last vertical column number (ie 52 not letter
> "AZ") in the print area.
>
> Using the below
>
> For Each a In Range("print_Area")
> MsgBox a
> Next
>
> is close but I actually only want to search a few columns within the print
> area
> ie
>
> For col = 1 to PrintAreaEdge - 5
>
> Thanks
>
>
>
> "Jason Lepack" wrote:
> > public sub mcphc()
> > dim r as integer, c as integer
> > ' rows 1 to 57
> > for r = 1 to 57
> > ' columns A to AZ
> > for c = 1 to 52
> > ' Print value of cell in immediate window
> > debug.print cells(r,c)
> > next c
> > next r
> > end sub

>
> > Cheers,
> > Jason Lepack

>
> > On Jan 30, 7:08 am, mcphc <m...@discussions.microsoft.com> wrote:
> > > I use the below to get the vertical edge of the print area.

>
> > > Range("Print_Area").Address

>
> > > The output of this is something like "$A$:1$AZ$57".

>
> > > I would like to run a macro that checks each cell in a row from column "A"
> > > to (as in the above) column "AZ"

>
> > > I would like to use something like

>
> > > For col = 1 to 52

>
> > > How do you represent AZ as 52? Or is there a better way of doing this? (I'm
> > > sure there is)- Hide quoted text -- Show quoted text -


 
Reply With Quote
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      30th Jan 2007
If you use Niek Otten's solution then it will select your cells wherever the
print range is even if it is moved

"mcphc" wrote:

> Thanks for the help guys but not quiet what I was looking for.
>
> The problem is the print area is always different so it could be
>
> For col= 1 to 52
>
> or
>
> For col = 1 to 30
>
> I need something like
>
> For col= 1 to PrintAreaEdge
>
> where PrintAreaEdge is the last vertical column number (ie 52 not letter
> "AZ") in the print area.
>
> Using the below
>
> For Each a In Range("print_Area")
> MsgBox a
> Next
>
> is close but I actually only want to search a few columns within the print
> area
> ie
>
> For col = 1 to PrintAreaEdge - 5
>
> Thanks
>
> "Jason Lepack" wrote:
>
> > public sub mcphc()
> > dim r as integer, c as integer
> > ' rows 1 to 57
> > for r = 1 to 57
> > ' columns A to AZ
> > for c = 1 to 52
> > ' Print value of cell in immediate window
> > debug.print cells(r,c)
> > next c
> > next r
> > end sub
> >
> > Cheers,
> > Jason Lepack
> >
> > On Jan 30, 7:08 am, mcphc <m...@discussions.microsoft.com> wrote:
> > > I use the below to get the vertical edge of the print area.
> > >
> > > Range("Print_Area").Address
> > >
> > > The output of this is something like "$A$:1$AZ$57".
> > >
> > > I would like to run a macro that checks each cell in a row from column "A"
> > > to (as in the above) column "AZ"
> > >
> > > I would like to use something like
> > >
> > > For col = 1 to 52
> > >
> > > How do you represent AZ as 52? Or is there a better way of doing this? (I'm
> > > sure there is)

> >
> >

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      30th Jan 2007
Sub Tester1()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, cell As Range
Set rng = ActiveSheet.Range(ActiveSheet.PageSetup.PrintArea)
Set rng1 = rng.Rows(1).Cells
Set rng2 = rng.Columns(1).Cells
For j = rng1(1).Column To rng1(rng1.Count).Column - 5
For i = rng2(1).Row To rng2(rng2.Count).Row
Set cell = Cells(i, j)
cell.Interior.ColorIndex = 3
Next i, j

End Sub

--
Regards,
Tom Ogilvy



"mcphc" wrote:

> Thanks for the help guys but not quiet what I was looking for.
>
> The problem is the print area is always different so it could be
>
> For col= 1 to 52
>
> or
>
> For col = 1 to 30
>
> I need something like
>
> For col= 1 to PrintAreaEdge
>
> where PrintAreaEdge is the last vertical column number (ie 52 not letter
> "AZ") in the print area.
>
> Using the below
>
> For Each a In Range("print_Area")
> MsgBox a
> Next
>
> is close but I actually only want to search a few columns within the print
> area
> ie
>
> For col = 1 to PrintAreaEdge - 5
>
> Thanks
>
> "Jason Lepack" wrote:
>
> > public sub mcphc()
> > dim r as integer, c as integer
> > ' rows 1 to 57
> > for r = 1 to 57
> > ' columns A to AZ
> > for c = 1 to 52
> > ' Print value of cell in immediate window
> > debug.print cells(r,c)
> > next c
> > next r
> > end sub
> >
> > Cheers,
> > Jason Lepack
> >
> > On Jan 30, 7:08 am, mcphc <m...@discussions.microsoft.com> wrote:
> > > I use the below to get the vertical edge of the print area.
> > >
> > > Range("Print_Area").Address
> > >
> > > The output of this is something like "$A$:1$AZ$57".
> > >
> > > I would like to run a macro that checks each cell in a row from column "A"
> > > to (as in the above) column "AZ"
> > >
> > > I would like to use something like
> > >
> > > For col = 1 to 52
> > >
> > > How do you represent AZ as 52? Or is there a better way of doing this? (I'm
> > > sure there is)

> >
> >

 
Reply With Quote
 
=?Utf-8?B?bWNwaGM=?=
Guest
Posts: n/a
 
      30th Jan 2007
That got it! Cheers Tom

"Tom Ogilvy" wrote:

> Sub Tester1()
> Dim rng As Range, rng1 As Range
> Dim rng2 As Range, cell As Range
> Set rng = ActiveSheet.Range(ActiveSheet.PageSetup.PrintArea)
> Set rng1 = rng.Rows(1).Cells
> Set rng2 = rng.Columns(1).Cells
> For j = rng1(1).Column To rng1(rng1.Count).Column - 5
> For i = rng2(1).Row To rng2(rng2.Count).Row
> Set cell = Cells(i, j)
> cell.Interior.ColorIndex = 3
> Next i, j
>
> End Sub
>
> --
> Regards,
> Tom Ogilvy
>
>
>
> "mcphc" wrote:
>
> > Thanks for the help guys but not quiet what I was looking for.
> >
> > The problem is the print area is always different so it could be
> >
> > For col= 1 to 52
> >
> > or
> >
> > For col = 1 to 30
> >
> > I need something like
> >
> > For col= 1 to PrintAreaEdge
> >
> > where PrintAreaEdge is the last vertical column number (ie 52 not letter
> > "AZ") in the print area.
> >
> > Using the below
> >
> > For Each a In Range("print_Area")
> > MsgBox a
> > Next
> >
> > is close but I actually only want to search a few columns within the print
> > area
> > ie
> >
> > For col = 1 to PrintAreaEdge - 5
> >
> > Thanks
> >
> > "Jason Lepack" wrote:
> >
> > > public sub mcphc()
> > > dim r as integer, c as integer
> > > ' rows 1 to 57
> > > for r = 1 to 57
> > > ' columns A to AZ
> > > for c = 1 to 52
> > > ' Print value of cell in immediate window
> > > debug.print cells(r,c)
> > > next c
> > > next r
> > > end sub
> > >
> > > Cheers,
> > > Jason Lepack
> > >
> > > On Jan 30, 7:08 am, mcphc <m...@discussions.microsoft.com> wrote:
> > > > I use the below to get the vertical edge of the print area.
> > > >
> > > > Range("Print_Area").Address
> > > >
> > > > The output of this is something like "$A$:1$AZ$57".
> > > >
> > > > I would like to run a macro that checks each cell in a row from column "A"
> > > > to (as in the above) column "AZ"
> > > >
> > > > I would like to use something like
> > > >
> > > > For col = 1 to 52
> > > >
> > > > How do you represent AZ as 52? Or is there a better way of doing this? (I'm
> > > > sure there is)
> > >
> > >

 
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
Reference a number from a different column in a formula rhhince Microsoft Excel Worksheet Functions 2 9th Nov 2008 11:15 PM
how do I link a reference number in text to the reference list =?Utf-8?B?TGluZGEgQW5u?= Microsoft Word Document Management 1 17th May 2007 04:44 PM
Reference a Column by Number John Michl Microsoft Excel Programming 4 1st Jun 2006 10:01 PM
Find Column Reference Number kathy.aubin@gmail.com Microsoft Excel Discussion 2 11th Feb 2006 12:25 AM
reference to column (not known) and certain row number =?Utf-8?B?Z2FiYQ==?= Microsoft Excel Programming 3 15th Nov 2004 01:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:41 AM.