Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code cleanup


I am using this code 30 times to "reset" 30 commandbuttons on a
worksheet.
There must be a more elegant way? Any assistance much appreciated

Cheers,

Peter (new to VBA)

With ThisWorkbook.Sheets("Benefits").CommandButton1
If Range("a100").Value < "" Then
..BackColor = &HFFC0C0
Else
..BackColor = &HE0E0E0
End If
End With


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=502302

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Code cleanup


With ThisWorkbook.Sheets("Benefits")

SetButton .CommandButton1, .range("A100")
SetButton .CommandButton2, .range("A101")
'...etc
end with

Sub SetButton(cb as object, rng as range)
if rng.value<"" then
cb.BackColor = &HFFC0C0
else
cb.BackColor = &HE0E0E0
end if
end sub


Tim




--
Tim Williams
Palo Alto, CA


"peter.thompson"
<peter.thompson.21t3fa_1137547201.8604@excelforu m-nospam.com wrote in
message news:peter.thompson.21t3fa_1137547201.8604@excelfo rum-nospam.com...

I am using this code 30 times to "reset" 30 commandbuttons on a
worksheet.
There must be a more elegant way? Any assistance much appreciated

Cheers,

Peter (new to VBA)

With ThisWorkbook.Sheets("Benefits").CommandButton1
If Range("a100").Value < "" Then
BackColor = &HFFC0C0
Else
BackColor = &HE0E0E0
End If
End With


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile:

http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=502302



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code cleanup


Thanks Tim

Cheers

Peter


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=502302

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
Data cleanup sjs Excel Worksheet Functions 1 September 16th 09 03:37 PM
Code cleanup help please peter.thompson[_8_] Excel Programming 5 December 22nd 05 07:08 AM
Log File CleanUp [email protected][_2_] Excel Programming 1 December 7th 04 06:19 PM
Leo Heuser format cleanup code, and a question GatesAntichrist Excel Programming 3 July 2nd 04 04:18 AM
Source Data Code Cleanup Help John Michl[_2_] Excel Programming 2 August 18th 03 09:01 PM


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