macro for repeat task and format interior

Hi All,
I'm trying to check out repeated value on column Q and the hightlighted
entire cell on the left.I put the code that found from Sample,and trying
to modified it but I made a mistake.I can't select entire cell on the left,
I just can highlight 2 cell ( offset(0.-3) and the cell on column A).Please
help how to select entire cell to the left without interupted by blank cell.

And also I want to put the copy of higlighted cell value to a new workbook.

Thank's.

Rgds,


Shiro


Sub Duplicate_Serial_Number()

   Dim eX As Integer
   Dim cell_in_loop As Range

   eX = ActiveSheet.Evaluate("COUNTIF(Q:Q,"">1"")")

If eX = 0 Then
MsgBox "There is no duplicated serial number ", vbExclamation _
+ vbOKOnly, "No Duplicated Data"
Else
For Each cell_in_loop In Range("Q16:Q50000")
  If cell_in_loop.Value > 1 And _
  cell_in_loop.Value <> "" Then
    With cell_in_loop.Offset(0, -3).End(xlToLeft).Interior
        .ColorIndex = 6
        .Pattern = xlSolid
    End With
  End If
Next
End If
End Sub



0
shiro (16)
5/20/2008 9:15:38 AM
excel 39879 articles. 2 followers. Follow

1 Replies
677 Views

Similar Articles

[PageSpeed] 10

One way:

Option Explicit
Sub Duplicate_Serial_Number()

    Dim myCell As Range
    Dim LastRow As Long
    Dim myRng As Range
    Dim myRngToShade As Range
    
    With ActiveSheet
        'clean up any previous shading
        .Cells.Interior.ColorIndex = xlNone
        LastRow = .Cells(.Rows.Count, "Q").End(xlUp).Row
        Set myRng = .Range("Q16:Q" & LastRow)

        If Application.Max(myRng) < 2 Then
            MsgBox "There is no duplicated serial number ", vbExclamation _
                + vbOKOnly, "No Duplicated Data"
        Else
            For Each myCell In myRng.Cells
                If myCell.Value > 1 Then
                    Set myRngToShade = .Range(.Cells(myCell.Row, "A"), _
                                                  .Cells(myCell.Row, "N"))
                    With myRngToShade.Interior
                        .ColorIndex = 6
                        .Pattern = xlSolid
                    End With
                End If
            Next myCell
        End If
    End With
        
End Sub

=======
Colors are pretty, but I like to use that extra column (Q) and then use
data|Filter|autofilter to see the duplicates.  



shiro wrote:
> 
> Hi All,
> I'm trying to check out repeated value on column Q and the hightlighted
> entire cell on the left.I put the code that found from Sample,and trying
> to modified it but I made a mistake.I can't select entire cell on the left,
> I just can highlight 2 cell ( offset(0.-3) and the cell on column A).Please
> help how to select entire cell to the left without interupted by blank cell.
> 
> And also I want to put the copy of higlighted cell value to a new workbook.
> 
> Thank's.
> 
> Rgds,
> 
> Shiro
> 
> Sub Duplicate_Serial_Number()
> 
>    Dim eX As Integer
>    Dim cell_in_loop As Range
> 
>    eX = ActiveSheet.Evaluate("COUNTIF(Q:Q,"">1"")")
> 
> If eX = 0 Then
> MsgBox "There is no duplicated serial number ", vbExclamation _
> + vbOKOnly, "No Duplicated Data"
> Else
> For Each cell_in_loop In Range("Q16:Q50000")
>   If cell_in_loop.Value > 1 And _
>   cell_in_loop.Value <> "" Then
>     With cell_in_loop.Offset(0, -3).End(xlToLeft).Interior
>         .ColorIndex = 6
>         .Pattern = xlSolid
>     End With
>   End If
> Next
> End If
> End Sub

-- 

Dave Peterson
0
petersod (12004)
5/20/2008 11:37:58 AM
Reply:

Similar Artilces:

2007: How to notify multiple people when a task is completed?
I know that the Status Manager for the task will get notified when a resource submits task updates, but we want the Status Manager to be the PM for all tasks. Is there a way to automatically notify other people when a particular task completes? TT -- The only way to address this issue is through custom software development. Therefore, I would suggest you repost this question in the microsoft.public.project.developer newsgroup and allow our developer friends to guide you. Hope this helps. -- Dale A. Howard [MVP] VP of Educational Services msProjectExperts http://www.m...

Macro warning with no macros
I have a workbook that when I try to open it I get the warning tellin me it contains macros and asking whether I want to Enable or Disabl them. I put no macros, no VB scripts, nothing at all in the workboo other than standard Excel formulas and some charts. I developed it i Excel 2002, SP-2, but have moved it back and forth between tw computers, the other which has Excel 97. Regardless of whether Enable or Disable or change the security settings so as not to get th warning, once the workbook is open even if I go t Tools-Macro-Macros... it lists no macros. How can I find out what's cau...

Macro
Can anybody tell me how to kick off a macro automatically as file is opened? Regards ...

Formating Form
Is it possible to format form to look just like a button? (i.e. withou caption area, without x button -- Message posted from http://www.ExcelForum.com ...

Is there a formular or format to change 1 to one
Is there a formular or format to change a number "1" into the word "one". Hi Kevin, See: http://www.xldynamic.com/source/xld.xlFAQ0004.html --- Regards, Norman "Kevin" <Kevin@discussions.microsoft.com> wrote in message news:3C099B0B-82F6-44FB-AD72-B0F726256F96@microsoft.com... > Is there a formular or format to change a number "1" into the word "one". See http://www.xldynamic.com/source/xld.xlFAQ0004.html -- HTH RP (remove nothere from the email address if mailing direct) "Kevin" <Kevin@discussions.micro...

Macro
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: intel Hi, I'm thinking of buying Mac: Office 2008, but before I do I want to check that I will be able to download Scritpsmart collection of templates without any glitches: <http://www.bbc.co.uk/writersroom/scriptsmart/faq.shtml> Does anyone know if I can do this? Regards, SP. In article <ee98ff5.-1@webcrossing.caR9absDaxw>, StregaItalia@officeformac.com wrote: > Version: 2008 > Operating System: Mac OS X 10.4 (Tiger) > Processor: intel > > Hi, > > I'm thinking of buying Mac: Of...

Date Format / Pivot Table Grouping
Hi Folks: I've imported 4,000+ records from a Filemaker database. About 70% of the dates come in formatted as mo/da/yr and are right justifed About 30% come in as yr/mo/da and are left justifed Setting up a pivot table, I'm not able to do a year group (I guess becasue of the dating) I'm not able to change the format of the 30% Is there a way to change yr/mo/da to mo/da/yr - or any other suggestions ?? Many thanks Steve Sort the dates and the yr/mo/da entries should be grouped at the bottom of the list. Select the yr/mo/da entries Choose Data>Text to Columns Click Next, N...

"Free Stock Trading Resources for you" "Knowledge is wealth" is the oft repeated, but absolute truth. And to add on to your knowledge arsenal, here are a few Excellent and Educative resources absolu
"Free Stock Trading Resources for you" "Knowledge is wealth" is the oft repeated, but absolute truth. And to add on to your knowledge arsenal, here are a few Excellent and Educative resources absolutely Free..The aim is to ensure that you Succeed on the Financial front. Check these out... May be it could mark the difference between Failure and Success. ---------------------------------------------------------------------------------------------------------------------------------------- Elliott Wave Video Crash Course http://www.elliottwave.com/a.asp?url=/wave/VideoCrashCo...

Run macro automatically.
How do I make a macro run automatically when a worksheet it is attached to is loaded? right click on the sheet tab>view code>left window worksheet>right window activate -- Don Guillett SalesAid Software donaldb@281.com "Excel macro" <Excel macro@discussions.microsoft.com> wrote in message news:DD7AF1E3-9263-4523-AC49-A43ABA1AB9D0@microsoft.com... > How do I make a macro run automatically when a worksheet it is attached to is > loaded? I am unable to find "activate " when I right click on worksheet. ( i assume that you are referring to the windo...

Help with macro/and or formula?
Perhaps this is a silly question, but i just can't figure out how t format this worksheet. The problem is that a lot of the cells hav numbers in them with negative signs in the back instead of in the fron (ie. 23-) and i was wondering if anyone knew of a macro/formula i coul use to quickly fix this problem for all the cells. I would b extremely grateful. Thanks -- brefed1 ----------------------------------------------------------------------- brefed15's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3557 View this thread: http://www.excelforum.com/showthre...

Attached Toolbars Macros
Excel 2003 I have a custom tool bar, this tool bar has several items, each item is pointing to a VBA code. This tool bar is attached to the worksheet. I've copied this spreadsheet to several computers. After I copied the spreadsheet I decided to rename the spreadsheet, after I renamed the spreadsheet the Toolbar Item's macros were still pointing to the old name, I reasigned each tool bar item to the current spreadsheet, saved the spreadsheet and everything was working on my computer, but when I re-copied the new spreadsheet to other computers and I clicked on the Toolbar Item...

Protected sheets and running macros
i have a sheet with a macro ran by a normal button at the top. Howeve when i protect the worksheet where ever i click on the sheet the macr executes. Can any one offer any advice on how to stop this? Thanks Robert -- Message posted from http://www.ExcelForum.com hi, i am not able to reproduce the problem, hence i may not be able t provide a panacea for that issue. here is what i suggest. i have a sheet that has a macro that is run when a control toolbo button (that is, not a form button) is clicked. this sheet is protected based on the user logged in. what i have don is to protect t...

Repeat header in report
Hi I am wanting to repeat a header on a report to the next page but the repeat section option is not available when I double click on the selector for the properties box? any other way of doing this. Are you attempting to print the REPORT header on each page? That can't be done, but you can move the controls in the report header to the Page Header section if you want it to repeat on every page. Page headers automatically print on every page. Group headers should not be a problem, you should be able to set the repeat section option for them. -- John Spencer Access MVP 2002-2005, ...

Conditional Formats #2
I have to somehow apply a compound conditional format to a worksheet that is only partially shown below. Here is my requirements which are difficult to explain, The correct answers to a multiple choice test are shown in row 2, columns B,D,F,H Students were asked to gauge their confidence in their answers, on a scale from 1-3 which are shown in C,E,G,I I need to conditionally format the answers so that they are Bold Italics if the correct answer appears and color code the cells with the answers depending upon the confidence level (on color for a 1, another for 2, and a third for a 3). ...

Macro to remove rows?
Hi, I receive thousands of rows of data from an extract that comes from a database. The data extract automatically generates page headers that need to be removed, and I would love to automate this process. The headers do have a pattern to them, but I'm not clever enough to figure out a good way to use that to write a macro. The first row of the header starts with hyphens ------------------------------- Then there's a variable number of rows of header data to delete followed by another row of hyphens ------------------------------- Then 2 additional rows that must be deleted. The nu...

Macro Freezes Reading Pane
I have a macro that Sends/Receives Tasks from Project Server into Outlook Tasks. Everything is working fine, except one weird thing that happens. I have the Timer set on the macro and it starts as soon as Outlook starts. The macro gets the tasks from ProjectServer every hour. As soon as the macro starts running the Reading pane freezes in the Inbox. If i stop the macro then Reading pane is back to normal. Can anyone please tell me if there is something I can do in VBA to fix this annoying issue. Thanks a lot ...

Calling on a macro within a macro!
Hey All!! Quick Question - How do you call up a macro within a current macro? I have one big macro and I need it to jump to several other macros when it runs! Does it matter where the other macros are stored or is it better to have them all in one module? Help appreciated Thnx! Hi Mellowe, '=============>> Public Sub Main() 'Your code Call One 'your code End Sub '<<============= '=============>> Public Sub One() MsgBox "Hi from One" End Sub '<<============= > Does it matter where the other macros are stored or ...

Format Records alternating colours.
Hi I would like to have aternating rows differnet colours. eg. customer no 123 red 123 red 456 green 456 green 456 green 789 red 789 red Can you tell excel to do this? mike Try this: Insert a blank (helper) column before your data. (I'll assume it will be Col_A. Col_B will list customers) A2: =IF(B2=B1,A1,NOT(A1)) Copy A2 down as far as you need Select from B2 down and to the right as far as you have data ...with B2 as the active cell. From the Excel Main Menu: <format><conditional formatting> Condition_1: Formula is: =$A2 Click the [Format] button ....select the Re...

Retain Field Format From Excel
I have an excel file that I'm importing to Access. This field consists of "time"...hours, minutes, seconds. The format in excel is set to "Custom" - [h]:mm:ss. The data elements look like 150:27:50, 2:30:25, etc... The time stays the same for some records but others change. For example...150:27:50 becomes 6:27:50 AM when imported. If someone can help me figure a way to retain the format for all records I would greatly appreciate it. Thank You, Lisa W. 150 divided by 24 = 6.25 or 6 and 1/4 days which is displayed a 6 AM. You need to use a ...

shortcut keys to macros
Hi, Is it at all possible to assign shortcut keys to macros in Outlook? Thx, Hans ...

Chart repeats in report
Hi, I have form based charts and tables and reports as sub-objects in one report, "Appendix". This takes one report header and nine section headers, no footers or detail section used. However, I noticed, as I built "Appendix", that a peculiar effect has happened, which to my, ignorant eye appears to be random. The effect is that some charts are repeated on the next page, and the following pages, for several more pages. As they repeat they gradually change vertical height on the Appendix report's pages. That is, the same chart (or table) repeats on several ...

NAICS Code
Hello, I have a list of NAICS codes formatted as numbers that I would like to format as hierarchical text. Current List 10 12 101 112 Desired List 10 101 112 12 Does anyone know how to change the cell format so that the "Current List" becomes the "Desired List"? Thank you in advance for your help. It looks like you could preformat that column as text and enter your values as text. Then you could sort the data as text. Some versions of excel will ask if you want to sort values that look like numbers as numbers. You should say no to that prompt. And just changing t...

help Unable to record Macro !!!!!!!
I want to record a macro in excel.But as soon as I click record Macro it says "unable to record" macro. Got no help in excel help.I do this same thing in word and it's working. Please help It's urgent for me !!!1 Have a look here http://groups.google.com/groups?as_epq=unable%20to%20record&as_ugroup=microsoft.public.excel.* -- Don Guillett SalesAid Software donaldb@281.com "ash" <anonymous@discussions.microsoft.com> wrote in message news:3e0b01c42ae5$45333e00$a401280a@phx.gbl... > I want to record a macro in excel.But as soon as I click > record...

Macro that password protects a sheet
I am attempting to create a macro that can open a protected sheet, change something, and then protect it again. I continue to have an issue with the macro not entering the password. Is this possible to do/fix? Thanks, Ryan ..open password="mypassword" -- Don Guillett SalesAid Software donaldb@281.com "Ryan" <Ryan@discussions.microsoft.com> wrote in message news:D4780ED8-CA1D-4284-97BC-3576160D998E@microsoft.com... > I am attempting to create a macro that can open a protected sheet, change > something, and then protect it again. I continue to have an iss...

Footer Macro?
Hi Months ago I read a Public Sub Macro that read the selection of a drop down list in a combo box and placed it in the center Footer at the same time it also placed the date in the right Footer and tme in the left footer. I have searched most of the regular sites including this one and cannot find it anywhere --- Can anyone help with my search. Any help much appreciated Cheers ---- Mully ...