Conditional Text Formatting

  • Thread starter Thread starter routeram
  • Start date Start date
R

routeram

Hi,

Is there a way to do this?

B1 - F cm-2 (-2 superscripted)
B2 - C cm-2 (-2 superscripted)

B3 must contain B1 or B2 depending on a condition. I want to preserv
the formatting (the superscripts) which the if statement does not do.

Thanks
 
How to do with macros?

Using the worksheet calculate event? How to do so efficiently?
 
It depends on what's changing and how it's changing.

Here my trigger cell was A1 of the same sheet and it was changing by the user
typing something in.

rightclick on the worksheet tab and select view code. Paste this in the window:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim ToCell As Range
Dim FromCell As Range
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("a1")) Is Nothing Then Exit Sub

Set ToCell = Me.Range("B3")

If Target.Value < 3 Then
Set FromCell = Me.Range("B1")
Else
Set FromCell = Me.Range("b2")
End If

Application.EnableEvents = False
FromCell.Copy _
Destination:=ToCell
Application.EnableEvents = True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top