+ Reply to Thread
Results 1 to 14 of 14

Looking for color in column and msgbox

Hybrid View

  1. #1
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Looking for color in column and msgbox

    Hi all,

    I need macro to check the range L3:L2500 for colorindex = 3 and if its found show the massege box or if not then go next.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Looking for color in column and msgbox

    Try this:

    Sub check_color()
    Dim Rng As Range
    
    Set Rng = Sheets("Sheet3").Range("L3:L2500")
    
    For Each r In Rng
    If r.Interior.ColorIndex = 3 Then
        MsgBox r.Address & " colorindex = 3"
    End If
    Next r
    
    End Sub

  3. #3
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Looking for color in column and msgbox

    Stop with
    Set Rng = Sheets("Sheet3").Range("L3:L2500")
    "out of range"

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Looking for color in column and msgbox

    Change sheet name Sheet3 to your real sheet name.

  5. #5
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Looking for color in column and msgbox

    I think I now the problem. If I fill the color manual then works ok, but when the color is from Conditional Formating then it's not.

  6. #6
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Looking for color in column and msgbox

    I did it zbor. That's the full code I want to use it:
    Sub AutoShape12_Click()
    Dim FilVal As String
    Dim DataRow As Range
    Dim DataCell As Range
    Dim Rng As Range
    
    Set Rng = Sheets("Arkusz1").Range("L3:L2500")
    
    For Each r In Rng
    If r.Interior.ColorIndex = 3 Then
        MsgBox r.Address & " colorindex = 3"
    End If
    Next r
    
    With ActiveSheet.Range("A2").CurrentRegion.Offset(1, 0)
        FilVal = InputBox(Prompt:="Enter the Pallet Number you want to print", _
        Title:="Input")
        If FilVal = vbNullString Then
            Exit Sub
        Else
            .AutoFilter 7, FilVal
        End If
        If .SpecialCells(12).count = 26 Then MsgBox "Nothing to Print!": .AutoFilter: Exit Sub
        
    CheckDate:
    WhatDate = InputBox("Enter the shipping date in format DD/MM/YYYY and AM/PM:")
    If WhatDate = vbNullString Then
    MsgBox "Enter the shipping date!"
    GoTo CheckDate
    Else
    Sheets("ShipmentDocket").Select
    Range("D14").Value = WhatDate
    End If
        
        'kopiowanie wierszy
        Intersect(.Columns("H:N"), .SpecialCells(xlVisible)).Copy
        'przenoszenie danych na arkusz wydruku
        With Worksheets("ShipmentDocket")
            'wklejanie danych
            .Range("A16").PasteSpecial xlPasteColumnWidths
            .Range("A16").PasteSpecial xlPasteAll
            '.Columns("E").Delete
            .Range("E16:E5000").Cells.Delete
                    
            Set DataRow = .UsedRange.Rows(17)
            Do While DataRow.Cells(1, 1) <> ""
               DataRow.Copy
               DataRow.Insert xlShiftDown
               For Each DataCell In DataRow.Cells
                    Select Case DataCell.Column
                    Case 2, 3, 4
                        DataCell.Value = "*" & DataCell.Value & "*"
                        DataCell.Font.Name = "FFontCode39H3"
                     Case Else
                        DataCell.Value = ""
                    End Select
               Next
               Set DataRow = DataRow.Offset(1, 0)
            Loop
      
            With .PageSetup
               .LeftMargin = Application.CentimetersToPoints(1)
               .RightMargin = Application.CentimetersToPoints(1)
               .LeftHeader = "&""Arial""&26&B SWORDS Delivery - Pallet No. " & FilVal
               '.PrintTitleRows = "$2:$2"
            End With
             .Range("A16:G5000").Columns.AutoFit
             '.Columns("A:F").EntireColumn.AutoFit
             .PrintPreview
                      
             .Range("A15:G5000").Cells.Clear
        End With
         .AutoFilter
     End With
    Sheets("Live").Select
    
    End Sub

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Looking for color in column and msgbox

    Yes. Works if cell is colored in red.
    For Conditional Formatting why don't you use CF criteria to check your data?

  8. #8
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Looking for color in column and msgbox

    That's what I do. CF is checking the match between column K&L and if its different then colour in red. And the macro above is printing me report. But I'm not suppose to do that when red colour is in L. That why I wanted to add the msgbox before my code. Is there anything I can do about it?

  9. #9
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Looking for color in column and msgbox

    Upload example workbook.
    Make sure to remove all private informations but leave only what's important to understend problem.

  10. #10
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Looking for color in column and msgbox

    Here you go zbor.
    Attached Files Attached Files
    Last edited by Rufles; 03-14-2014 at 08:56 AM.

  11. #11
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Looking for color in column and msgbox

    Your sheet is protected

  12. #12
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Looking for color in column and msgbox

    Sorry protection removed ;-)
    Attached Files Attached Files

  13. #13
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Looking for color in column and msgbox

    Perhaps
    Sub Rufles()
    Dim l As Long
    
    For l = 3 To Range("L" & Rows.count).End(xlUp).Row
        If IsEmpty(Cells(l, 12)) = False Then
            If IsNumeric(Cells(l, 12)) And Cells(l, 12) <> Cells(l, 11) Then
                MsgBox Cells(l, 12).Address(False, False) & " is Red!"
            End If
        End If
    Next l
    End Sub
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  14. #14
    Registered User
    Join Date
    02-08-2014
    Location
    Dublin
    MS-Off Ver
    Excel 2013
    Posts
    70

    Re: Looking for color in column and msgbox

    Solus Rankin this is what I was looking for. Didn't think that way - excellent.
    Thank you all for help.
    Problem SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Problem with VBA Editor uses lower case on some lines (ex. msgbox instead of MsgBox)
    By stubbsj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-14-2013, 06:59 PM
  2. Color if date in column n and stop color at column n
    By dalet in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-19-2009, 01:55 PM
  3. Msgbox background color
    By toocold in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2006, 05:36 AM
  4. Change color of text segment in msgbox
    By brucemc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-10-2006, 11:25 AM
  5. [SOLVED] blank value for row and column in msgbox
    By jjfjr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2005, 08:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1