Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Formatting columns of unknown length

Hi,
I wish to format certain columns (say A, B, F) to uppercase, but I don't
know how long the columns will become.
Is there a 'catch all' paramer rather than stating the range?
tia
--
Traa Dy Liooar

Jock
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Formatting columns of unknown length

Hi Jock,

Try this as worksheet code

Sub stance()
lastrowA = Range("A65536").End(xlUp).Row
lastrowB = Range("B65536").End(xlUp).Row
lastrowF = Range("F65536").End(xlUp).Row

Set Range1 = Range("A1:A" & lastrowA)
Set Range2 = Range("B1:B" & lastrowB)
Set Range3 = Range("F1:F" & lastrowF)

Set range4 = Union(Range1, Range2, Range3)
For Each c In range4
c.Value = UCase(c.Value)
Next
End Sub

Mike

"Jock" wrote:

Hi,
I wish to format certain columns (say A, B, F) to uppercase, but I don't
know how long the columns will become.
Is there a 'catch all' paramer rather than stating the range?
tia
--
Traa Dy Liooar

Jock

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ian Ian is offline
external usenet poster
 
Posts: 238
Default Formatting columns of unknown length

Private Sub Test()
Dim lastrow As Long
For rownum = 1 To Cells(Rows.Count, "A").End(xlUp).Row
Cells(rownum, "A").Value = UCase(Cells(rownum, "A").Value)
Next
For rownum = 1 To Cells(Rows.Count, "B").End(xlUp).Row
Cells(rownum, "A").Value = UCase(Cells(rownum, "B").Value)
Next
For rownum = 1 To Cells(Rows.Count, "F").End(xlUp).Row
Cells(rownum, "A").Value = UCase(Cells(rownum, "F").Value)
Next
End Sub

Repeat for other columnscolumns B & F

--
Ian
--
"Jock" wrote in message
...
Hi,
I wish to format certain columns (say A, B, F) to uppercase, but I don't
know how long the columns will become.
Is there a 'catch all' paramer rather than stating the range?
tia
--
Traa Dy Liooar

Jock



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Formatting columns of unknown length

Thanks guys.
I couldn't get either to work tho.
When there's more than one sub in a worksheet, I would presume that it will
be actioned in the order the code is set out in.
Is there any recommended default order in which to set things out ar does it
really not matter too much?
--
Traa Dy Liooar

Jock


"Ian" wrote:

Private Sub Test()
Dim lastrow As Long
For rownum = 1 To Cells(Rows.Count, "A").End(xlUp).Row
Cells(rownum, "A").Value = UCase(Cells(rownum, "A").Value)
Next
For rownum = 1 To Cells(Rows.Count, "B").End(xlUp).Row
Cells(rownum, "A").Value = UCase(Cells(rownum, "B").Value)
Next
For rownum = 1 To Cells(Rows.Count, "F").End(xlUp).Row
Cells(rownum, "A").Value = UCase(Cells(rownum, "F").Value)
Next
End Sub

Repeat for other columnscolumns B & F

--
Ian
--
"Jock" wrote in message
...
Hi,
I wish to format certain columns (say A, B, F) to uppercase, but I don't
know how long the columns will become.
Is there a 'catch all' paramer rather than stating the range?
tia
--
Traa Dy Liooar

Jock




  #5   Report Post  
Posted to microsoft.public.excel.programming
Ian Ian is offline
external usenet poster
 
Posts: 238
Default Formatting columns of unknown length

You need to run the macro. If you need it to run automatically, you need to
trigger it in some way.

One option is to use Worksheet_SelectionChange(ByVal Target As Range) in
place of Test(). This will run the macro every time you select a different
cell. Not efficient as it means the macor runs repeatedly. Another, possibly
better option is to use Worksheet_Activate() or Worksheet_Deactivate(). This
will not run as often, but you won't see the effects of the macro until you
have deactivated and reactivated the sheet (normally after closing and
reopening). Other options are available, both a Worksheet and Workbook level
(including Before save and Before close). The choice is yours as it depends
when you want to see the data updated.

--
Ian
--
"Jock" wrote in message
...
Thanks guys.
I couldn't get either to work tho.
When there's more than one sub in a worksheet, I would presume that it
will
be actioned in the order the code is set out in.
Is there any recommended default order in which to set things out ar does
it
really not matter too much?
--
Traa Dy Liooar

Jock


"Ian" wrote:

Private Sub Test()
Dim lastrow As Long
For rownum = 1 To Cells(Rows.Count, "A").End(xlUp).Row
Cells(rownum, "A").Value = UCase(Cells(rownum, "A").Value)
Next
For rownum = 1 To Cells(Rows.Count, "B").End(xlUp).Row
Cells(rownum, "A").Value = UCase(Cells(rownum, "B").Value)
Next
For rownum = 1 To Cells(Rows.Count, "F").End(xlUp).Row
Cells(rownum, "A").Value = UCase(Cells(rownum, "F").Value)
Next
End Sub

Repeat for other columnscolumns B & F

--
Ian
--
"Jock" wrote in message
...
Hi,
I wish to format certain columns (say A, B, F) to uppercase, but I
don't
know how long the columns will become.
Is there a 'catch all' paramer rather than stating the range?
tia
--
Traa Dy Liooar

Jock






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
Finding a string of unknown length in a string of unknown length, Help! Hankjam[_2_] Excel Discussion (Misc queries) 8 July 3rd 08 06:49 PM
Merge to Columns with Unknown length Steve M[_9_] Excel Programming 5 June 6th 06 06:58 PM
Formatting Data Columns of various length with Macros Wfc Excel Programming 3 September 6th 05 01:48 PM
Formatting Data Columns of various length with Macros wfc Excel Programming 2 August 31st 05 11:56 AM
Sum unknown length column data in VBA John[_80_] Excel Programming 3 June 26th 04 03:32 AM


All times are GMT +1. The time now is 12:27 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"