Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Mulit-column number formatting

I'm trying to format a sequence of columns, but without success. I've used:

Sub x()

Dim i As Integer, iCol As Integer

For i = 1 To 47
iCol = 12 + 7 * (i - 1)
Range(Cells(, iCol), Cells(, iCol + 2)).NumberFormat = "0.00"
Next i
End Sub

I've tried columns(icol, icol+2) as well. Any ideas?

TIA,
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Mulit-column number formatting

Of course, should be "multi-column."

"MikeM" wrote:

I'm trying to format a sequence of columns, but without success. I've used:

Sub x()

Dim i As Integer, iCol As Integer

For i = 1 To 47
iCol = 12 + 7 * (i - 1)
Range(Cells(, iCol), Cells(, iCol + 2)).NumberFormat = "0.00"
Next i
End Sub

I've tried columns(icol, icol+2) as well. Any ideas?

TIA,
Mike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Mulit-column number formatting

How about:

Option Explicit
Sub x()

Dim i As Long
dim iCol As Integer

For i = 1 To 47
iCol = 12 + 7 * (i - 1)
activesheet.cells(1,icol).resize(1,2).entirecolumn .NumberFormat = "0.00"
Next i
End Sub

You must be using xl2007 for all those columns, right?

MikeM wrote:

I'm trying to format a sequence of columns, but without success. I've used:

Sub x()

Dim i As Integer, iCol As Integer

For i = 1 To 47
iCol = 12 + 7 * (i - 1)
Range(Cells(, iCol), Cells(, iCol + 2)).NumberFormat = "0.00"
Next i
End Sub

I've tried columns(icol, icol+2) as well. Any ideas?

TIA,
Mike


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Mulit-column number formatting

Yes, I have Excel 2007. I tried your fixt, but it didn't seem to work. So
instead I used

Columns(iCol).NumberFormat = "0.00"
Columns(iCol + 1).NumberFormat = "0.00"
Columns(iCol + 2).NumberFormat = "0.00"

Why can't multiple columns be referenced?

"Dave Peterson" wrote:

How about:

Option Explicit
Sub x()

Dim i As Long
dim iCol As Integer

For i = 1 To 47
iCol = 12 + 7 * (i - 1)
activesheet.cells(1,icol).resize(1,2).entirecolumn .NumberFormat = "0.00"
Next i
End Sub

You must be using xl2007 for all those columns, right?

MikeM wrote:

I'm trying to format a sequence of columns, but without success. I've used:

Sub x()

Dim i As Integer, iCol As Integer

For i = 1 To 47
iCol = 12 + 7 * (i - 1)
Range(Cells(, iCol), Cells(, iCol + 2)).NumberFormat = "0.00"
Next i
End Sub

I've tried columns(icol, icol+2) as well. Any ideas?

TIA,
Mike


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Mulit-column number formatting

I resized the range to 2 columns. I see that you wanted 3 columns.

Changing the .resize(1,2) to .resize(1,3) should work ok.

But I don't know why it didn't work for you. It worked fine for me in xl2003
(until I ran out of columns).

Maybe you could explain how it failed.

MikeM wrote:

Yes, I have Excel 2007. I tried your fixt, but it didn't seem to work. So
instead I used

Columns(iCol).NumberFormat = "0.00"
Columns(iCol + 1).NumberFormat = "0.00"
Columns(iCol + 2).NumberFormat = "0.00"

Why can't multiple columns be referenced?

"Dave Peterson" wrote:

How about:

Option Explicit
Sub x()

Dim i As Long
dim iCol As Integer

For i = 1 To 47
iCol = 12 + 7 * (i - 1)
activesheet.cells(1,icol).resize(1,2).entirecolumn .NumberFormat = "0.00"
Next i
End Sub

You must be using xl2007 for all those columns, right?

MikeM wrote:

I'm trying to format a sequence of columns, but without success. I've used:

Sub x()

Dim i As Integer, iCol As Integer

For i = 1 To 47
iCol = 12 + 7 * (i - 1)
Range(Cells(, iCol), Cells(, iCol + 2)).NumberFormat = "0.00"
Next i
End Sub

I've tried columns(icol, icol+2) as well. Any ideas?

TIA,
Mike


--

Dave Peterson


--

Dave Peterson
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
Formatting cells in a column with conditional formatting? shamor Excel Discussion (Misc queries) 8 May 19th 08 10:11 PM
Which version of Office does support mulit-processors? Eric Excel Discussion (Misc queries) 2 September 7th 07 09:44 AM
to convert columns to rows having mulit independent group columns Quacy Excel Worksheet Functions 1 August 22nd 06 11:20 PM
How do I set up a transport cost with mulit origins, destin,svcs [email protected] Excel Worksheet Functions 0 July 12th 06 07:03 PM
Mulit Users in a shared protected workbook Roxi Excel Discussion (Misc queries) 1 June 1st 05 06:40 PM


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