Macro/VBA For gathering info

Antonow

New Member
Joined
Aug 19, 2015
Messages
39
Hello World!

Well, it's been a while since i've been messing with excel VBA and Macros and now I need to develop something thus..
I need the help of the best ones there is!

Basically I have A Data worksheet, with several informations.
Like, factory code, dealer code, Number of the product, mainteneance.. stuff like that.
I need to make a new tab with something like, you input the Factory code, or the Products code and hits this search button.

The final product should give you all the info you need in that tab without having to go in the other ones. Like I can't remember how to make a VBA that looks in every line of a certain range and gives me the info I need.
I've tried to do it and it searches only the first line of every worksheet :(
Plus, i need to implement the possibility to add a new input, select in what worksheet it should go and press save.

I've done something like it but it was really waaaay back there.. can't remember how I've done it :(

I know it's a long shot, with a lot of try and error.. But hopefully we will be able to do it! :)

I will post more info about the worksheet here later. end of the month is a mess for everyone heh.

But I would be glad if you guys helped me out with some "generic" code for that.

Thank you all in advance!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I'm sure someone will help. Please post where the data is and how U want to display/store the output (ie. sheet name(s), columns and rows). HTH. Dave
 
Upvote 0
how bout a form, the a combo box to pick CodeType: Factory, Product, or Dealer
a text box for the code
a button to 'find'

at button click event:
Code:
sub btnFind_click()
on error goto errFind

sheets(cboCodeType).select
range("A1").select

    Columns("A:A").Select
    Selection.Find(What:=txtCode, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

   if activecell.value  = txtCode then
         'collect values in this row
              'x = activecell.value 

         'make new sheet
       sheets.add

         'paste data to new tab
   endif
errFind:
end sub
 
Last edited:
Upvote 0
Dealer CodeDescriptionFactory codeProjectFactoryStatusVulnerabilityFamilyLiberação Para produçãoCritical productCritical Proccess
ZM001077Thermostat button MOULD ZM001077 ZM00107716F1ACNãoF10011

<tbody>
</tbody>

This is an example of what I have in this worksheet called (Moulds list), this is one product out of 237.
Basically what I need is a macro that is able to both get the information of the Mould or factory code typed in this cell, and to update and add another product if needed.
Like, The very first worksheet is "Information" where I have cells to input either Mould number or Factory code, a button, several other cell that will contain the information about this Product or mould.

Like this.

Dealer CodeZM001077Search ButtonReset fields
Factory code16Update Button
DescriptionThermostat button MOULD ZM001077 ZM001077
ProjectTool Station0Critical product1Control Level12
FactoryF1SO Tool Station0Critical Proccess1Maintenance complexity3
StatusACHot chamber codeHc321Quality History1Preventive level2
FamilyF100Hot Chamber dealerHRSVolume4

<tbody>
</tbody>

This information it gets from the moulds list worksheet
 
Last edited:
Upvote 0
Again, "Please post where the data is and how U want to display/store the output (ie. sheet name(s), columns and rows). " Dave
 
Upvote 0
Ok! Here it goes.

So, i've made an Input sheet. Where you enter a code in the Cell "C6" and using a VLOOKUP it will gather all the info from that Mould and place it where it has to be.
To make it easier to understand I've separated into information field and update field.
This spreadsheet (Information field), is locked, the only cell you can change is "C6" to enter the code and the Vlookup will get the data. Cells Will be shown like ("C#")

Fact. Code:("A6")Enter Code("C6")Description:("E6")Water cooler shelter ("G6")Project:("Q6")Dinamarca("S6")
Supplier Code("A7")ZM223252("C7")
Factory("A8")0("C8")S.O Tooling("E8")0("G8") Action("i8")0("k8")Production Release("M8")0("O8")Control level("Q8")0("S8")
Status("A9")Active("C9")H.C. Code("E9")0("G9") Cost ("i9")0("k9")Product Criticy("M9")0("O9")Meintenance Complexity("Q9")0("S9")
Vulnerability("A10")No("C10")H.C. Manufacturer("E10")0("G10") Internal/External Service ("i10")0("k10")Proccess Criticy("M10")0("O10")Preventive level("Q10")0("S10")
Family("A11")F600("C11")H.C. Diameter("E11")0("G11")Execution Time (Internal Tooling)("i11")0("k11")Quality History("M11")0("O11")% Recycled drawing("Q11")0("S11")
Tooling("A12")0("C12")Pendency("E12")0("G12")Tooling Release("i12")0("k12")Volume("M12")0("O12")Hidraulic hitch("Q12")0("S12")

<tbody>
</tbody>

And it copies it to the (Update field) cells, shown below in the same sheet (input), so if you need to update, you change it and press the button "Update".
Like this:

Fact. Code:("A14")Enter Code("C14")Description:("E14")Water cooler shelter ("G14")Project:("Q14")Dinamarca("S14")
Supplier Code("A15")ZM223252("C15")
Factory("A16")0("C16")S.O Tooling("E16")0("G16") Action("i16")0("k16")Production Release("M16")0("O16")Control level("Q16")0("S16")
Status("A17")Active("C17")H.C. Code("E17")0("G17") Cost ("i17")0("k17")Product Criticy("M17")0("O17")Meintenance Complexity("Q17")0("S17")
Vulnerability("A18")No("C18")H.C. Manufacturer("E18")0("G18") Internal/External Service ("i18")0("k18")Proccess Criticy("M18")0("O18")Preventive level("Q18")0("S18")
Family("A19")F600("C19")H.C. Diameter("E19")0("G19")Execution Time (Internal Tooling)("i19")0("k19")Quality History("M19")0("O19")% Recycled drawing("Q19")0("S19")
Tooling("A20")0("C20")Pendency("E20")0("G20")Tooling Release("i20")0("k20")Volume("M20")0("O20")Hidraulic hitch("Q20")0("S20")

<tbody>
</tbody>

When the update button is pressed, it will get the information from C14:C:20, G14, G16:G20, K16:K20, O16:O20, S16:S20(underlined), and what I need the macro to do is to search for the Fact. Code from ("C14" Input) in ("A2:A243" Moulds list) and update the info that has been changed. (By update the info, i mean just to copy all the information that has been placed in the "Update field" mentioned before.)

Sheet Moulds List cells:

Fact. Code("A1")Description("B1")Supplier Code ("C1")Project("D1")Factory("E1")Status("F1")Vulnerability("G1")Family("H1")Tooling("i1")S.O. Tooling("J1")H.C. Code("K1")H.C. Manufacturer("L1")H.C. Diameter("M1")Pendency("N1")Action("O1") Cost("P1")Internal/External Service("Q1")Execution Time (Internal Tooling)("R1")Tooling Release("S1")Production Release("T1")Product Criticy("U1")Proccess Criticy("V1")Quality History("W1")Volume("X1")Control level("Y1")Maintenance Complexity("Z1")Preventive level("AA1")% Recycled drawing("AB1")Hidraulic hitch("AC1")

<tbody>
</tbody>


If it's a bit confusing, i'm sorry, English is not my mother language..
Just message me and I will be pleased to try to explain it better
 
Last edited:
Upvote 0
And if possible, for new Moulds (Products), use the update field to make the input of that new Mould in the Moulds list. :) Thank you all for the help in advance
 
Upvote 0
Maybe trial this and see if this is close. Dave
Code:
Sub test()
Dim Lastrow As Integer, Cnt As Integer
'data in "A2:A" & lastrow
With Sheets("Moulds")
    Lastrow = .Range("A" & .Rows.Count).End(xlUp).Row
End With
For Cnt = 2 To Lastrow
If Sheets("Input").Range("C" & 14).Value = Sheets("Moulds").Range("A" & Cnt).Value Then
'move data here
'eg for description
Sheets("Input").Range("E" & 14).Value = Sheets("Moulds").Range("B" & Cnt).Value
'etc.
Exit For
End If
Next Cnt
End Sub
 
Upvote 0
Thanks for the fast reply!

Got a couple things to adjust tho.
The code works, but it's doing the opposite, instead of updating the info in the "Moulds" it is looking for the info available in the "Moulds" and updating it in the "Input".
Here are some images.

https://imgur.com/GQPLSNo
In here I use the Data check field to gather the info from the "Moulds" using VLOOKUP, once i have the info, I hit the button Copy to Update field. Where it copie and paste the info to the field below, in order for you to update what you need.

https://imgur.com/bmqEoFK
In here, I've updated the info needed. Next step should be click in the update button.

https://imgur.com/t9DULjo
Once the update button is pressed, the information that i've just entered is gone. It hasn't copied it to the "Moulds" sheet, instead, it checked the info in there and copied to the update field.

As you can see in the images and brief explanation, I need to use that Update Info Field to input the new information and then when I hit the Update button it updates that in the "Moulds". I've tried to update it in the "Moulds" tab manually and pressing update, it then gathered the info and placed it into "Input" Data check field.

I'm trying to adjust it, but no success so far.
Can you help me out?
 
Upvote 0
I've managed to fix it :)
The only thing I need now is this: If the "Fact. Code" is not found in "Moulds" Open a popup asking if it's a new code. If you Hit "Yes" it will add it into that tab "Moulds" under the last one available and if you hit "No" it will say something like "Invalid Code" and do nothing.

Is it possible? to do so?

Here's the code i have now:

Code:
Sub Update()Dim Lastrow As Integer, Cnt As Integer
'data in "A2:A" & lastrow
With Sheets("Moulds")
    Lastrow = .Range("A" & .Rows.Count).End(xlUp).Row
End With
For Cnt = 2 To Lastrow
If Sheets("Input").Range("C" & 14).Value = Sheets("Moulds").Range("A" & Cnt).Value Then
'move data here
'Supplier Code
Sheets("Moulds").Range("C" & Cnt).Value = Sheets("Input").Range("C" & 15).Value
'Factory
Sheets("Moulds").Range("E" & Cnt).Value = Sheets("Input").Range("C" & 16).Value
'Status
Sheets("Moulds").Range("F" & Cnt).Value = Sheets("Input").Range("C" & 17).Value
'Vulnerability
Sheets("Moulds").Range("G" & Cnt).Value = Sheets("Input").Range("C" & 18).Value
'Family
Sheets("Moulds").Range("H" & Cnt).Value = Sheets("Input").Range("C" & 19).Value
'Tooling
Sheets("Moulds").Range("I" & Cnt).Value = Sheets("Input").Range("C" & 20).Value
'Description
Sheets("Moulds").Range("B" & Cnt).Value = Sheets("Input").Range("G" & 14).Value
'S.O. Tooling
Sheets("Moulds").Range("J" & Cnt).Value = Sheets("Input").Range("G" & 16).Value
'H.C. Code
Sheets("Moulds").Range("K" & Cnt).Value = Sheets("Input").Range("G" & 17).Value
'H.C. Manufacturer
Sheets("Moulds").Range("L" & Cnt).Value = Sheets("Input").Range("G" & 18).Value
'H.C. Diameter
Sheets("Moulds").Range("M" & Cnt).Value = Sheets("Input").Range("G" & 19).Value
'Pendency
Sheets("Moulds").Range("N" & Cnt).Value = Sheets("Input").Range("G" & 20).Value
'Action
Sheets("Moulds").Range("O" & Cnt).Value = Sheets("Input").Range("K" & 16).Value
'Cost
Sheets("Moulds").Range("P" & Cnt).Value = Sheets("Input").Range("K" & 17).Value
'Internal/External Service
Sheets("Moulds").Range("Q" & Cnt).Value = Sheets("Input").Range("K" & 18).Value
'Execution Time (Internal Tooling)
Sheets("Moulds").Range("R" & Cnt).Value = Sheets("Input").Range("K" & 19).Value
'Tooling release
Sheets("Moulds").Range("S" & Cnt).Value = Sheets("Input").Range("K" & 20).Value
'Production release
Sheets("Moulds").Range("T" & Cnt).Value = Sheets("Input").Range("O" & 16).Value
'Product Criticy
Sheets("Moulds").Range("U" & Cnt).Value = Sheets("Input").Range("O" & 17).Value
'Proccess Criticy
Sheets("Moulds").Range("V" & Cnt).Value = Sheets("Input").Range("O" & 18).Value
'Quality history
Sheets("Moulds").Range("W" & Cnt).Value = Sheets("Input").Range("O" & 19).Value
'Volume
Sheets("Moulds").Range("X" & Cnt).Value = Sheets("Input").Range("O" & 20).Value
'Project
Sheets("Moulds").Range("D" & Cnt).Value = Sheets("Input").Range("S" & 14).Value
'Control Level
Sheets("Moulds").Range("Y" & Cnt).Value = Sheets("Input").Range("S" & 16).Value
'Mainance complexity
Sheets("Moulds").Range("Z" & Cnt).Value = Sheets("Input").Range("S" & 17).Value
'Preventive Level
Sheets("Moulds").Range("AA" & Cnt).Value = Sheets("Input").Range("S" & 18).Value
'%Recycled drawing
Sheets("Moulds").Range("AB" & Cnt).Value = Sheets("Input").Range("S" & 19).Value
'Hidraulich hitch
Sheets("Moulds").Range("AC" & Cnt).Value = Sheets("Input").Range("S" & 20).Value
'etc.
Exit For
End If
Next Cnt
    ActiveSheet.Unprotect "Pass"
Selection.ClearContents
    Range("C14:D14").Select
    Range("C14:D20,G16:H20,K16:L20,O16:P20,S14:T20,G14:P15").Select
    Range("G14").Activate
    Selection.ClearContents
    Range("C14:D14").Select
    ActiveSheet.Protect "Pass", True, True
End Sub

Thank you once again!!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top