+ Reply to Thread
Results 1 to 12 of 12

VBA Code to check Cell Value in another sheet, before copy match record to Sheet

  1. #1
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Hi there,

    Im currently working on a Simple Inventory file managing records of Machines that come in and out of my store.

    I have created a Form - InStore form, whereby i receive Machines and I input this details into the form and the record is saved inside my InStore Table.
    I have successfully coded this with some useful tips provided by helpful members on Excel Forum.

    Currently I have a Deploy Form, whereby I will Search for a Machine using a Serial Number. I have a button Event for this.

    I need some help with a bit of complex coding where by when Perform a Search using Serial Number in my Deploy Form, it will check if this value is found inside "InStore" Sheet, Column(A:A).
    If record is not found, a Pop-Up Box to appear to show the error and clear the cell. It its found the Cell will not be cleared.

    Upon Clicking on Submit i will need to copy the data from the Row (A:N) from Sheet(InStore) into my "Deploy" Sheet as the last record. The Row that was copied from "InStore" Sheet will be deleted as the data is blank.

    Appreciate your assistance on this.
    Attached Files Attached Files

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,914

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    For starters.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Quote Originally Posted by bakerman2 View Post
    For starters.

    Please Login or Register  to view this content.
    Thanks for the starter, however i tried this code, but its not working.
    Last edited by newbie1234; 02-16-2020 at 04:53 AM.

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,461

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Administrative Note:

    Please don't quote entire posts unnecessarily. They clutter threads and make them hard to read.
    Use the "Quick reply" instead
    Thanks

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,914

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    When I type a non existing serial number in Deploy Form C6 and click search I get a msgbox saying the number doesn't exist.

    So what is not working then ?

  6. #6
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Please Login or Register  to view this content.
    I have tried your code that you have provided and modified it to reference my sheets.

    Please Login or Register  to view this content.
    So when i execute this Code, i first try with a Non-existent serial number or with an Existing serial number i get an error saying Object Required.

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,914

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Sheet1 & Sheet8 are Sheet CodeNames while yours are the names that show on the worksheet tabs.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Apologies Bakerman2,

    I have tried the update code on my Form, when i click on the button this time it does not do any action.
    I do not receive a Msgbox nor does it clear the "C6" contents.

  9. #9
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Hi Bakerman2,

    I have tried this code instead for the Search and manage to get the Search Function work.

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Please Login or Register  to view this content.
    I have currently this code, whereby when it meets a Condition in my Deploy Form, it will execute Save_Record() upon the Click of the Save button.

    What it actually does is copy the Row found in InStore Sheet where it matches a value found in Sheets("Deploy Form").Range("C6") onto the next available row in Deploy Sheet and proceed to delete the source row.

    How can i amend my code to just copy the Row Data from from Column A to Column N instead of from all the columns. Since I have some vlookup formulas from Column M onwards referencing Table for some values
    I want my code to achieve 2 things, copy the data from InStore and along with some data found in DeployForm(Fixed A1:G1) over to my Deploy Table record.
    Last edited by newbie1234; 02-16-2020 at 06:59 AM.

  11. #11
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Please Login or Register  to view this content.
    I have manage to figure out on how to do the copying. However for this code, when im copying these range of cells to another sheet. its copyings the formula references that are found inside(A1:G1).
    How do i amend this code to include to save just Values only?

    ws3.Range("A1:G1").Copy ws2.Range("O" & lr2)

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,484

    Re: VBA Code to check Cell Value in another sheet, before copy match record to Sheet

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. Copy Range from One sheet to Another , depending upon record match.....Not working...
    By enggrahul78 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-06-2019, 06:54 AM
  2. VB script or macro to check rows of sheet 1 and match with sheet 2, if found copy to shet3
    By adityamishra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-27-2017, 12:50 PM
  3. Replies: 0
    Last Post: 09-16-2015, 01:18 PM
  4. [SOLVED] Match criteria between sheets and copy cell values to existing record in master sheet
    By Hirad001 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2015, 04:28 PM
  5. Replies: 5
    Last Post: 07-27-2015, 04:27 PM
  6. VBA Code Help PLS: Find Last Record on Sheet and Copy it Multiple TImes to Rows in Another
    By fadilrexhepi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2015, 08:33 AM
  7. VBA for copy record to sellected 2 sheet & clear entry sheet for new record
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-24-2012, 10:54 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