Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Business Applications
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel firefox hard drive hardware hijackthis internet keyboard laptop malware monitor network networking outlook problem processor recovery registry cleaner router safe mode screen slow sound spyware tdlwsp.dll trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: EXCEL 2007 VBA Help

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
Regulator's Avatar
Computer Specs
Junior Member with 14 posts.
 
Join Date: Nov 2009
Experience: Intermediate
04-Nov-2009, 02:19 PM #16
Zack, that blank row can be removed. If there is no match, I would like to get a message that says no match.
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 4,511 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
04-Nov-2009, 02:40 PM #17
You want a message for each? Or you want one stating which part numbers didn't match?
Regulator's Avatar
Computer Specs
Junior Member with 14 posts.
 
Join Date: Nov 2009
Experience: Intermediate
04-Nov-2009, 03:04 PM #18
Which ever is easier. I just would like some sort of message that makes it clear that there was no result because there was no match, not because of a formatting or formula issue.
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 4,511 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
04-Nov-2009, 03:52 PM #19
So, we can make a change event, that runs every time you make a change to column B's data (starting at row 14 and going down). This will lookup the data and populate that row of info. What about the columns that you haven't identified? I.e. PT, PS, MB and UM?
Regulator's Avatar
Computer Specs
Junior Member with 14 posts.
 
Join Date: Nov 2009
Experience: Intermediate
04-Nov-2009, 04:01 PM #20
All I'm concerned about is the unit price.
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 4,511 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
04-Nov-2009, 04:33 PM #21
Okay, try this, right click your worksheet tab (BOM1) and select View Code, paste this in there...

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim ws As Worksheet, rLook As Range, rFind As Range
    Const StartRow As Long = 14

    If Target.Column <> 2 Then Exit Sub
    If Target.Row < StartRow Then Exit Sub
    Set ws = ThisWorkbook.Sheets("Indentured BOM")
    Set rLook = ws.Columns(1)
    Set rFind = rLook.Find(What:=Target.Value, LookAt:=xlWhole, MatchCase:=True)
    If rFind Is Nothing Then
        Target.Offset(0, 9).Value = ""
    Else
        Target.Offset(0, 9).Value = rFind.Offset(0, 8).Value
    End If
    
End Sub
I think it should get you what you want.

HTH
Regulator's Avatar
Computer Specs
Junior Member with 14 posts.
 
Join Date: Nov 2009
Experience: Intermediate
04-Nov-2009, 04:44 PM #22
It works! Perfect! Just one more thing, can you extend the ranges to the end of the sheet?
Regulator's Avatar
Computer Specs
Junior Member with 14 posts.
 
Join Date: Nov 2009
Experience: Intermediate
04-Nov-2009, 04:57 PM #23
Okay, I lied here is the last thing, I have more than 1 BOM sheet. For illustration purposes I only put BOM1, in reality there's BOM2, BOM3, BOM4 etc...how can I modify the macro to account for this?
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 4,511 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
04-Nov-2009, 06:24 PM #24
Didn't I ask if this was the spreadsheet you were working with? This is what happens when you don't show your actual work. I didn't design a solution for your actual work, which means I'm doing twice the work now. And if I seem a little pissy it's cause I am. You have no idea how frustrating it is to do all of your work TWICE!

Okay, with that out of the way (thank you for letting me vent), please, please, please, post anything else about your spreadsheet we need to know about.
Regulator's Avatar
Computer Specs
Junior Member with 14 posts.
 
Join Date: Nov 2009
Experience: Intermediate
04-Nov-2009, 06:45 PM #25
Sorry!
I apologize, I messed up badly on this. Thank you for all your help and work. If you would be so kind to give me a second chance, I have attached the final workbook that is the actual template that I work from. Thanks again for your patience!
Attached Files
File Type: xls Test Data Rev 2.xls (166.5 KB, 3 views)
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 4,511 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
04-Nov-2009, 07:20 PM #26
It's not that I won't give a second chance, I just would like you to understand the frustration of doing the work twice. No worries really, I've gotta jet right now for class, but I can take a look at it later.
Regulator's Avatar
Computer Specs
Junior Member with 14 posts.
 
Join Date: Nov 2009
Experience: Intermediate
06-Nov-2009, 03:24 PM #27
Zack, I copied and pasted this code into the individual BOMs and it works great! I'm going to count this thread as SOLVED! Thanks again for your help!
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 4,511 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
08-Nov-2009, 11:35 PM #28
While that will work, it makes for a PITA, especially if you have to change any of the code. You're better off using one piece of code. You can do this by putting it in the ThisWorkbook module and making it work for all sheets...
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim rFind As Range
    Const StartRow As Long = 14
    If Left(Sh.Name, 3) <> "BOM" Then Exit Sub
    If Target.Column <> 2 Then Exit Sub
    If Target.Row < StartRow Then Exit Sub
    Set rFind = Sh.Columns(1).Find(What:=Target.Value, LookAt:=xlWhole, MatchCase:=True)
    If rFind Is Nothing Then
        Target.Offset(0, 9).Value = ""
    Else
        Target.Offset(0, 9).Value = rFind.Offset(0, 8).Value
    End If
End Sub
This code is UNTESTED by myself. Save your work before trying it out. You wouldn't need any of the other code in any of the other worksheets if this works for you, just this in your ThisWorkbook module.

HTH
Reply Bookmark and Share

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 02:12 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.