Consulting

Results 1 to 7 of 7

Thread: Mesage box in VBA

  1. #1

    Mesage box in VBA

    Hi, could someone help me with VB, i have a column,
    some cells in the column are red some are white after ruing a macro, some times no red at all - (conditional formatting ),
    So i want a message box to appear if i have any red cells,
    thank you

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is not easy to test for conditionally formatted cells, far better to test for the same criteria that sets it red. What is the condition?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    actually i color the whole column in red, the with conditional formation i make white cell, and the rest of them remain red, so are the red cells a want a message box,
    i use from red to white :

    = countif(rates,P11)

    and for making the white the empty (which are red) cells :

    =LEN(TRIM(M11))=0

  4. #4
    and here is my recorded macro :

    [VBA]Sub Rates()
    '
    ' Rates Macro
    '

    '
    Application.Goto Reference:="R11C11:R10000C11"
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 255

    End With
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
    "=COUNTIF(Rates,K11)"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriori ty
    With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorDark1

    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
    "=LEN(TRIM(K11))=0"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriori ty
    With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorDark1

    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Range("K11").Select
    End Sub[/VBA]

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That made absolutely no sense to me, and I am not clear what the CF is, the COUNTIF seems to do nothing, and the other just tests for data.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    i think i didn't explain correctly

    look i have two columns, with numbers, i the second column i introduce values sometime, and those values usually are the same like in first column, if the value is not in the first column i want that cell to be colored in red ( in the second column)
    i have to check the second columns (to see if i have those values in the first column) and if i don't have the number in the fist column, then i want the the cell red in the second column,

    i cannot introduce formula in the excel ( in cell A) because i have values in that cell,
    this should be dome in conditional formatting or in the VBR

  7. #7
    Good Morning
    the data in cell is changing all the time, and they are random, they are introduced by hand in the cell, so in this case the formula will be deleted , i cannot not introduce it all the, time, because this guys who will work with this sheet, they have no idea about formulas

Posting Permissions

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