Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default early beginner not satisfied with simple macro

Hi,
Although this macro works, is there a way to improve it ?

===start===

Option Explicit

Sub FormatHighestValue()
Dim c as Rang
Dim iEndRow as Integer
Dim iEndCol as String
iEndCol = ThisWorkbook.Sheets(1).Range("B2").End(xlToRight). Address
iEndRow = ThisWorbook.Sheets(1).Range("B2").End(xlDown).Row
iEndCol = Left(iEndCol, 2)
iEndCol = Right (iEndCol, 1)
ThisWorkbook.Range("B2" & ":" & iEndCol & iEndRow).Select
For Each c in Selection.Cells
If c.Value 1000 Then
c.Font.ColorIndex = 3
End If
next c
End Sub

===end===

I think code about iEndCol could be reduced...

Thanks in advance for your help.

Ppp

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default early beginner not satisfied with simple macro

There were a fair few errors in there, but the principle was okay

Sub FormatHighestValue()
Dim c As Range
Dim iEndRow As Integer
Dim iEndCol As String
With ThisWorkbook.Sheets(1)
iEndCol = .Range("B2").End(xlToRight).Column
iEndRow = .Range("B2").End(xlDown).Row
iEndCol = Left(iEndCol, 2)
iEndCol = Right(iEndCol, 1)
For Each c In .Range("B2" & ":", Cells(iEndRow, iEndCol))
If c.Value 1000 Then
c.Font.ColorIndex = 3
End If
Next c
End With
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"wbrowse" wrote in message
ups.com...
Hi,
Although this macro works, is there a way to improve it ?

===start===

Option Explicit

Sub FormatHighestValue()
Dim c as Rang
Dim iEndRow as Integer
Dim iEndCol as String
iEndCol = ThisWorkbook.Sheets(1).Range("B2").End(xlToRight). Address
iEndRow = ThisWorbook.Sheets(1).Range("B2").End(xlDown).Row
iEndCol = Left(iEndCol, 2)
iEndCol = Right (iEndCol, 1)
ThisWorkbook.Range("B2" & ":" & iEndCol & iEndRow).Select
For Each c in Selection.Cells
If c.Value 1000 Then
c.Font.ColorIndex = 3
End If
next c
End Sub

===end===

I think code about iEndCol could be reduced...

Thanks in advance for your help.

Ppp



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default early beginner not satisfied with simple macro

oki, thx

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
Simple problem, must be too early... AD108[_2_] Excel Programming 3 March 8th 07 03:27 PM
My guess it's a simple quesion, but I'm a beginner danham Excel Programming 6 September 24th 05 07:44 AM
Simple beginner question Jeff Roper[_3_] Excel Programming 0 November 11th 04 10:37 AM
Simple beginner question Jeff Roper[_2_] Excel Programming 2 November 11th 04 06:51 AM
Simple beginner question Jeff Roper Excel Programming 3 November 10th 04 01:20 PM


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