ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Conditional Formating (https://www.excelbanter.com/excel-discussion-misc-queries/162139-conditional-formating.html)

jk9533

Conditional Formating
 
I need to create a format based on a user condition. Example if the person
choose % on a cell the next cell in the following column should be formated
at % if the person chooses number then the next cell in the following column
should be formated as a whole number.

Any idea how to make this happen?


Dave Peterson

Conditional Formating
 
I don't think you'll be able to use format|Conditional formatting for this.

But maybe you could use data|validation to provide a list of options for the
formatting.

Then use a worksheet_Change event that applies the formatting you want to the
cell(s) that you want.

If you need help, you should provide the list of formatting options. The range
that should have its formatting changed and the version of excel that you're
using.

jk9533 wrote:

I need to create a format based on a user condition. Example if the person
choose % on a cell the next cell in the following column should be formated
at % if the person chooses number then the next cell in the following column
should be formated as a whole number.

Any idea how to make this happen?


--

Dave Peterson

JE McGimpsey

Conditional Formating
 
You can't use Conditional Formatting to change number format.

You could use an Event macro. For instance, if the "format" cell is A1
and the "number" cell is B1, put this in your worksheet code module
(right-click the worksheet tab and choose View Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If Not Intersect(.Cells, Range("A1")) Is Nothing Then
If Trim(.Text) = "%" Then
.Offset(0, 1).NumberFormat = "0%"
Else
.Offset(0, 1).NumberFormat = "0"
End If
End If
End With
End Sub


In article ,
jk9533 wrote:

I need to create a format based on a user condition. Example if the person
choose % on a cell the next cell in the following column should be formated
at % if the person chooses number then the next cell in the following column
should be formated as a whole number.

Any idea how to make this happen?



All times are GMT +1. The time now is 03:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com