Consulting

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 21 to 40 of 49

Thread: MACRO: IF THEN Statement (Multiple Criteria Match then Copy)

  1. #21
    Hi, For some reason the this code isn't showing the Sheet where the info is missing as I thought it would.. It is just showing the following:

    error_msg.jpg

    MsgBox colHeader & " not found in row " & colRow & " on " & sh.Name
    colNumber = CVErr(xlErrValue)
    Quote Originally Posted by Paul_Hossler View Post
    I changed the copy loop to use the values


                    For iCopy = LBound(aCopy, 1) + 1 To UBound(aCopy, 1)
                        rMAFFT.Cells(iMAFFT, aCopy(iCopy, 1)).Copy
                        rDeploy.Cells(iDeploy, aCopy(iCopy, 2)).PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                        rDeploy.Cells(iDeploy, aCopy(iCopy, 2)).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                    Next iCopy

  2. #22
    One more things sorry.. I would like to be able to copy cells from the Deployment Sheet to the MAFFT as well. I added the info on the Sample8.
    Attached Files Attached Files

  3. #23
    Hi,

    I would like to also be able to copy over these columns from the Deployment Sheet to the MAFFT Sheet based off of the same criteria as copying from the MAFFT to Deployment. Deployment sheet Headers, Company, First Name, Last Name, Address1, Address2, City, State, Zip, Phone, E-Mail Web Address from the Deployment Sheet to the MAFFT Sheet with Column Headers that are equal. See Sample 8... I would like this to be a Macro and not an automatic item..
    Quote Originally Posted by Paul_Hossler View Post
    I changed the copy loop to use the values


                    For iCopy = LBound(aCopy, 1) + 1 To UBound(aCopy, 1)
                        rMAFFT.Cells(iMAFFT, aCopy(iCopy, 1)).Copy
                        rDeploy.Cells(iDeploy, aCopy(iCopy, 2)).PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                        rDeploy.Cells(iDeploy, aCopy(iCopy, 2)).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                    Next iCopy
    Attached Files Attached Files

  4. #24
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by pawcoyote View Post
    Hi, For some reason the this code isn't showing the Sheet where the info is missing as I thought it would.. It is just showing the following:

    1. You hadn't asked for the sheet names. Didn't seem necessary since the macro only copies from MAFFT to Deployment, and only if the link field(s) do not have matching values you get the error message

    2. Change to this

            s = "No match found on " & wsDeploy.Name & " for ... " & vbCrLf & vbCrLf & vbCrLf
            For i = 2 To wsCrossRef.Cells(1, 1).End(xlDown).Row
                s = s & wsCrossRef.Cells(i, 1) & " = " & rMAFFT.Cells(iMAFFT, aMatch(i, 1)) & vbCrLf
            Next I
            MsgBox s & vbCrLf & " from " & wsMAFFT.Name
    3. I think this is what you were asking for

    Capture.JPG
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #25
    I will try that and also if you could look at the new thing I am trying to do with copying from deployment to MAFFT...

  6. #26
    Hi, I found that when I remove either the Config SN or MFG SN on the Deployment Sheet it doesn't remove or clear the data from the cells when I run the macro. I fixed the Zip code issue. Also on the Copy of the other cells back to the MAFFT. I would love your feedback.
    Quote Originally Posted by Paul_Hossler View Post
    1. You hadn't asked for the sheet names. Didn't seem necessary since the macro only copies from MAFFT to Deployment, and only if the link field(s) do not have matching values you get the error message

    2. Change to this

            s = "No match found on " & wsDeploy.Name & " for ... " & vbCrLf & vbCrLf & vbCrLf
            For i = 2 To wsCrossRef.Cells(1, 1).End(xlDown).Row
                s = s & wsCrossRef.Cells(i, 1) & " = " & rMAFFT.Cells(iMAFFT, aMatch(i, 1)) & vbCrLf
            Next I
            MsgBox s & vbCrLf & " from " & wsMAFFT.Name
    3. I think this is what you were asking for

    Capture.JPG

  7. #27

    Post

    Good morning,

    I would like to try to do the following if possible.

    1. If you remove Config SN or MFG SN on the Deployment Sheet I would like for it to remove or clear the data that was imported in from the MAFFT tool (Fields in the CrossRef Sheet) when I run the macro.
    2. I would like to also be able to copy over these columns from the Deployment Sheet to the MAFFT Sheet based off of the same criteria as copying from the MAFFT to Deployment. Deployment sheet Headers, Company, First Name, Last Name, Address1, Address2, City, State, Zip, Phone, E-Mail Web Address from the Deployment Sheet to the MAFFT Sheet with Column Headers that are equal. See Sample9... I would like this to be a Macro and not an automatic item.

    Attached Files Attached Files

  8. #28
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Logic check - Is this correct?

    1. Run macro MAFFT2Development

    2. After current logic, add new logic to

    If you remove Config SN or MFG SN on the Deployment Sheet I would like for it to remove or clear the data that was imported in from the MAFFT tool (Fields in the CrossRef Sheet) when I run the macro.
    3. On Deployment if "Configured Serial #" OR "Mfg. Configured Serial #" is blank, then how to identify the lines on Deployment since those are the two link fields?


    I would like to also be able to copy over these columns from the Deployment Sheet to the MAFFT Sheet based off of the same criteria as copying from the MAFFT to Deployment. Deployment sheet Headers, Company, First Name, Last Name, Address1, Address2, City, State, Zip, Phone, E-Mail Web Address from the Deployment Sheet to the MAFFT Sheet with Column Headers that are equal.

    4. Is this a new macro?

    5. Is this the logic:?

    If 'Deployment' [Configured Serial #] = 'MAAFT' [Oracle Config Serial Number (custom12)] AND 'Deployment' [Mfg. Serial Number] = 'MAAFT' [Serial Number] Then

    Copy the Col D fields for that line from Deployment to MAAFT

    ?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  9. #29
    I hope this helps.

    Logic check - Is this correct?

    I had to update the Config Serial Number header name and I had to move column to a new location. “Config Serial Number (custom12)” (Sample10)

    1. Run macro MAFFT2Development

    2. After current logic, add new logic to


    If you remove Config SN or MFG SN on the Deployment Sheet I would like for it to remove or clear the data that was imported in from the MAFFT tool (Fields in the CrossRef Sheet) when I run the macro.

    3. On Deployment if " Oracle Config Serial Number (custom12)" OR "Mfg. Serial Number” is blank, then how to identify the lines on Deployment since those are the two link fields?

    3.a. If "Oracle Config Serial Number (custom12)" or "Mfg. Serial Number" on the Deployment sheet are Blank then clear.contents (not formatting) in the fields listed in the CrossRef Sheet (Column C). This can be a separate Macro. IT does not have to be in the MAFFT2Development Macro.

    I would like to also be able to copy over these columns from the Deployment Sheet to the MAFFT Sheet based off of the same criteria as copying from the MAFFT to Deployment. Deployment sheet Headers, Company, First Name, Last Name, Address1, Address2, City, State, Zip, Phone, E-Mail Web Address from the Deployment Sheet to the MAFFT Sheet with Column Headers that are equal.

    4. Is this a new macro?

    4.a. Yes new macro to keep it simple unless building it into the first Macro is easier.


    5. Is this the logic:?

    Same logic as the MAFFT2Development Macro, If 'Deployment' [Oracle Config Serial Number (custom12)]= 'MAAFT' [Oracle Config Serial Number (custom12)] AND 'Deployment' [Mfg. Serial Number] = 'MAAFT' [Serial Number] Then

    Copy the Col D fields on the CrossRef Sheet for that match from Deployment to MAAFT
    Attached Files Attached Files

  10. #30
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    I tried running the macro and the column headers were changed

    I stopped after fixing the first 3:

    Capture.JPG

    MAFFT col header is 'Device', not 'Devices'
    Deployment and MAFFT col headers were 'Montly' and not 'Monthly'
    Deployment and MAFFT col header were 'Site/Location', and not 'Site Location'


    Since the macros match on column headers to copy data, they have to be matched
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  11. #31
    That is very odd I only changed one header I will fix and repost. I am sorry about that...
    Quote Originally Posted by Paul_Hossler View Post
    I tried running the macro and the column headers were changed

    I stopped after fixing the first 3:

    Capture.JPG

    MAFFT col header is 'Device', not 'Devices'
    Deployment and MAFFT col headers were 'Montly' and not 'Monthly'
    Deployment and MAFFT col header were 'Site/Location', and not 'Site Location'


    Since the macros match on column headers to copy data, they have to be matched

  12. #32
    I have updated the sample to have the correct headers on both sheets.

    I would like to keep this simple. I would like to add the Copy from the Deployment Sheet to the MAFFT Sheet based on the same criteria as the original copy and paste. I identified the fields in the CrossRef tab which fields I wish to copy from the Deployment to the MAFFT.
    Attached Files Attached Files

  13. #33
    Hi Paul, I added an updated Sample 11 in a previous post. I hope that help. All I want to do is be able to do is create another macro to copy the items in the CrossRef Column 4 from Deployment to MAFFT.
    Quote Originally Posted by Paul_Hossler View Post
    I tried running the macro and the column headers were changed

    I stopped after fixing the first 3:

    Capture.JPG

    MAFFT col header is 'Device', not 'Devices'
    Deployment and MAFFT col headers were 'Montly' and not 'Monthly'
    Deployment and MAFFT col header were 'Site/Location', and not 'Site Location'


    Since the macros match on column headers to copy data, they have to be matched

  14. #34
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    OK

    Didn't forget, just busy

    I started to pull out all the common code make it general

    Probably soon
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  15. #35
    Hi not a problem I totally understand. I just wanted to be sure I kept updating as I made a change.

  16. #36
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,641
    Is this a question or an assignment ? (to be paid for)

  17. #37
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by snb View Post
    Is this a question or an assignment ? (to be paid for)

    https://en.wikipedia.org/wiki/Feature_creep


    This started out as using a simple event handler to take a US State in one column and enter an associated US Region in another

    http://www.vbaexpress.com/forum/show...ered&highlight=


    There have more than a few additional requests

    I don't mind implementing them (on a 'when I get around to it' basis) but if I had known the final (OK, current) scope I would have either

    1. Have passed it by, or

    2. Planned the architecture a lot better



    I really don't mind doing it, but had I had a better long range view of the requirements, I would have done things a lot more gracefully
    Last edited by Paul_Hossler; 04-17-2017 at 09:38 AM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  18. #38
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,641
    The absence of any input from the part of the OP stikes me as non compatible with the goal of a forum.

  19. #39
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    @pawcoyote --

    I generalized the original sub

    There's Deployment2MAFFT and MAFFT2Deployment to check out

    Please use enough real / representitive data to check it out

    You have line numbers in col A and formulas to the far right in otherwise empty lines which cause a lot of extra lines to be checked. The line numbers in A I can handle but do you need the far right formulas?
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  20. #40
    Good morning,

    No I do not need the formulas and the line numbers are not necessary as well... Thank you!

Posting Permissions

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