Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jun 2015
    Posts
    13
    Thanks
    11
    Thanked 0 Times in 0 Posts

    I need macro excel for find a condtion value into range and replace a value from another sheet

    Hi,

    I want to create a macro that my work easier formatting of cells in an Excel sheet. The requirement is that each cell contents include the following values:

    81, 82, 83, 121, 123

    and the last digit to be formatted as an exponent. To do this, initially I want to write in cell numbers from 1 to 5 (each digit corresponding to a format of the list), these figures will then be replaced by macro values to be taken from a sheet.
    Can you help me?

    for replace3.xlsm

  2. #2
    New Lounger
    Join Date
    Jun 2015
    Posts
    3
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Try:
    Code:
    Sub Macro1()
    Dim Rng As Range
        For Each Rng In Worksheets("dumbrava").Range("D5:AH22")
            If Val(Rng) > 0 And Val(Rng) <= 5 Then
                Rng = Choose(Val(Rng), "8 1", "8 2", "8 3", "12 1", "12 3")
                Rng.Characters(Start:=3, Length:=1).Font.Superscript = True
                Rng.Font.Underline = True
            End If
        Next Rng
    End Sub
    Last edited by RetiredGeek; 2015-06-06 at 19:31. Reason: Added Code Ring

  3. The Following User Says Thank You to Rod Gill For This Useful Post:

    doru.ditu.3 (2015-06-07)

  4. #3
    New Lounger
    Join Date
    Jun 2015
    Posts
    13
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Hi,

    Thanks so much!
    Your code is running for the first three items from the list, namely 81, 82, 83, but does not apply to the other two, 121 and 123 respectively.
    Can you least like to review?
    Best regards!
    Last edited by doru.ditu.3; 2015-06-06 at 23:58. Reason: Thanks

  5. #4
    New Lounger
    Join Date
    Jun 2015
    Posts
    3
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Try:
    Sub Macro1()
    Dim Rng As Range
    For Each Rng In Worksheets("dumbrava").Range("D5:AH22")
    If Val(Rng) > 0 And Val(Rng) <= 5 Then
    Rng = Choose(Val(Rng), "8 1", "8 2", "8 3", "12 1", "12 3")
    Rng.Characters(Start:=Len(Rng.Text), Length:=1).Font.Superscript = True
    Rng.Font.Underline = True
    End If
    Next Rng
    End Sub

  6. The Following User Says Thank You to Rod Gill For This Useful Post:

    doru.ditu.3 (2015-06-07)

  7. #5
    New Lounger
    Join Date
    Jun 2015
    Posts
    13
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Your code run perfectly.
    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •