Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Macro help/advice please!

Hi,

I am trying to write a macro do automatically format 6 cells in a row.
This I've managed, but find I'm stuck on the next bit. I want the
macro to repeat the format in the next row (and subsequent rows) until
the row has no data in it. The macro so far is

Range("F18:J18").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With

End Sub

I want to repeat this until cell F in the next row is empty. I suspect
I need something like a "do until" loop, but can't see how to write it
as all the examples I've seen don't seem to cover formatting.

Can anyone please point me in the right direction to get this
achieved?
--
Cheers

Peter

Please remove the invalid to reply
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Macro help/advice please!

Hi Peter,

One way to loop is the following

Dim i As Integer
Dim LastRow As Integer

LastRow = Cells(Cells.Rows.Count,"F").End(xlUp).Row

For i = 18 to LastRow
Range("F" & i &":J" & i).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Next i
End Sub


HTH
Cheers
Carim

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Macro help/advice please!

On 31 Aug 2006 01:40:38 -0700, "Carim" wrote:

Hi Peter,

One way to loop is the following

Dim i As Integer
Dim LastRow As Integer

LastRow = Cells(Cells.Rows.Count,"F").End(xlUp).Row

For i = 18 to LastRow
Range("F" & i &":J" & i).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Next i
End Sub


HTH
Cheers
Carim


Hope this helps? Too right it does - it's does exactly what I want!

many thanks

--
Cheers

Peter

Please remove the invalid to reply
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Macro help/advice please!

On 31 Aug 2006 01:40:38 -0700, "Carim" wrote:

Hi Peter,

One way to loop is the following

Dim i As Integer
Dim LastRow As Integer

LastRow = Cells(Cells.Rows.Count,"F").End(xlUp).Row

For i = 18 to LastRow
Range("F" & i &":J" & i).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Next i
End Sub


HTH
Cheers
Carim


Hi Carim,

As ever, one solution poses another question!

The macro works beautifully, but when you merge cells that have data
in them you get a warning message:

"The selection contains multiple data. Merging into one cell will keep
the upper-left most data only"

Is there a way to make the macro auto accept this warning for each
line?

--
Cheers

Peter

Please remove the invalid to reply
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Macro help/advice please!

Hi Peter,

Merged cells are a nightmare and should be avoided as much as possible
....
they were created for purely "cosmetic reasons" ...

However, to bypass your problem, try using SendKeys to skip the warning
....

HTH
Cheers
Carim



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Macro help/advice please!

On 31 Aug 2006 04:13:00 -0700, "Carim" wrote:

Hi Peter,

Merged cells are a nightmare and should be avoided as much as possible
...
they were created for purely "cosmetic reasons" ...

However, to bypass your problem, try using SendKeys to skip the warning
...

HTH
Cheers
Carim


Hi Carin,

Yes, I agree that merged cells are pain, I just whish I hadn't used
them when producing the spreadsheet (which needed to mimic a paper
form.

--
Cheers

Peter

Please remove the invalid to reply
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Macro help/advice please!

Peter,

'application.displayalerts = false' will turn of all warnings.

Mike.

"Peter" wrote in message
...
On 31 Aug 2006 01:40:38 -0700, "Carim" wrote:

Hi Peter,

One way to loop is the following

Dim i As Integer
Dim LastRow As Integer

LastRow = Cells(Cells.Rows.Count,"F").End(xlUp).Row

For i = 18 to LastRow
Range("F" & i &":J" & i).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Next i
End Sub


HTH
Cheers
Carim


Hi Carim,

As ever, one solution poses another question!

The macro works beautifully, but when you merge cells that have data
in them you get a warning message:

"The selection contains multiple data. Merging into one cell will keep
the upper-left most data only"

Is there a way to make the macro auto accept this warning for each
line?

--
Cheers

Peter

Please remove the invalid to reply



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
pls advice dribler2 Excel Worksheet Functions 0 December 29th 06 02:22 PM
Advice on Creating an Excel Formula or Macro - PLEASE HELP!!!! So Tru Geo Excel Worksheet Functions 1 June 27th 06 07:15 PM
Advice Please? Greg[_27_] Excel Programming 3 May 9th 06 10:51 AM
Advice please Greg New Users to Excel 2 February 24th 05 12:19 PM
macro advice tommy Excel Programming 2 August 27th 04 06:45 PM


All times are GMT +1. The time now is 06:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"