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.
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.
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
Never use Merged Cells in Excel
Stop with
"out of range"![]()
Set Rng = Sheets("Sheet3").Range("L3:L2500")
Change sheet name Sheet3 to your real sheet name.
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.
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
Yes. Works if cell is colored in red.
For Conditional Formatting why don't you use CF criteria to check your data?
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?
Upload example workbook.
Make sure to remove all private informations but leave only what's important to understend problem.
Here you go zbor.
Last edited by Rufles; 03-14-2014 at 08:56 AM.
Your sheet is protected
Sorry protection removed ;-)
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 clickingbelow 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."
Solus Rankin this is what I was looking for. Didn't think that way - excellent.
Thank you all for help.
Problem SOLVED.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks