Why not simply use conditional format?

Sam Mathai Chacko

On Thu, Mar 29, 2012 at 8:22 PM, Tiffany <tiffany....@gmail.com> wrote:

> Hi -
>
> I'm a little new to VBA but have managed to put together a macro that half
> achieves its intended purpose.
>
> Depending on what is chosen in a data validation cell (any cell in range
> S8 to AL8), the macro is supposed to change the format of 296 cells below
> the data validation cell:
>
>    - If "Amount" is chosen in the data validation cell, the format in
>    cells below should change to "Comma" style (i.e., 0.00).  This works.
>    - If "Percent" is chosen in the data validation cell, the format in
>    cells below should change to "0.000000%".  This doesn't work.  I'm stumped
>    since the language looks right to me and no debugging error pops up.  Any
>    ideas?
>
> The macro I have now is copied below.  Any help you could provide would be
> greatly appreciated.
>
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
>
> Dim SAType As Range
> Set SAType = Range("S8:AL8")
>
> If Not Application.Intersect(Target, SAType) Is Nothing Then
> On Error Resume Next
>     Select Case SAType
>             Case "Amount"
>                 Target.Offset(1, 0).Range("A1:A296").Style = "Comma"
>             Case "Percent"
>                 Target.Offset(1, 0).Range("A1:A296").NumberFormat =
> "0.000000%"
>     End Select
> End If
> End Sub
>
>
>  --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>



-- 
Sam Mathai Chacko

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to