Message box and mark by lookup in other sheet

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
882
Hi all, I would like to write a macro so that when i run it, to appears a message box with text ("Please Enter Group's Code"), and when i enter the group's code, automatically lookup through column "A" and marks the debtors' names whose are belong the code and also it's transactions in column "C" which contains text or numbers in column "B". The debtors groups are in another excel sheet in the following bath: c:/my documents/Groups. (Sheet Groups). In this sheet the debtors' names are in col. "A" and its' codes in col. "B". Note that the database sheet contains more than 35000 rows and the groups are more than 40 different codes. Please see below extracts spreadsheets for what i requested. Ignore any borders of the below spreadsheets. Any help or advice would be great appreciated. Best regards.


F.1.
ABCDE
1
2DateReferenceDebitCredit
3
4ABCD LTD
5
613/03/2014INV-78901.499,400,00
719/03/2014CNN-3487-1.499,400,00
8
9Totals0,000,00
10
11EFGH LTD
12
1301/08/2008REC-25670,00948,75
1420/08/2008INV-80956.325,000,00
1526/08/2008REC-26750,006.325,00
16
17Totals6.325,007.273,75
18
19IJKLM LTD
20
2120/05/2013REC-27500,00619,50
2223/12/2013INV-8128929,250,00
2331/12/2013REC-28800,00929,25
24
25Totals929,251.548,75

<tbody>
</tbody>





F.2.
ABCDE
1DateReferenceDebitCredit
2
3ABCD LTD10
4
513/03/2014INV-7890101.499,400,00
619/03/2014CNN-348710-1.499,400,00
7
8Totals0,000,00
9
10EFGH LTD10
11
1201/08/2008REC-2567100,00948,75
1320/08/2008INV-8095106.325,000,00
1426/08/2008REC-2675100,006.325,00
15
16Totals6.325,007.273,75
17
18IJKLM LTD10
19
2020/05/2013REC-2750100,00619,50
2123/12/2013INV-812810929,250,00
2231/12/2013REC-2880100,00929,25
23
24Totals929,251.548,75
25

<tbody>
</tbody>



F.3.
AB
1Debtor's NameCode
2ABCD LTD10
3EFGH LTD10
4IJKLM LTD10

<tbody>
</tbody>
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Is it possible to create a formula using VLOOKUP in order to resolve my issue? I would be creat appreciated to advice me. Kind regards
 
Upvote 0
Any advice how can i use formula VLookup so that to search and find information through other spreadsheet i would
greatly appreciated. Kind regards
 
Upvote 0
Since no one has so far replied, here is my suggestion.
Try this and if found useful, alter as needed.
Sheet 1
No Name Pin
416 David 602172
412 Stephen 603107
654 Barnabas 603152
361 Chandran 603082


Sheet 2
No Name Pin
416 David 602172
654 Barnabas 603152
414 Abraham 603118


Copy this Function in a Module.
Code:
Function SafeVlookup(lookup_value, _
                        range_lookup, col_index, error_value) As Variant
'http://stackoverflow.com/questions/17100782/vba-excel-vlookup-crashes-my-program-when-no-match-found
'http://www.cpearson.com/excel/errorhandling.htm
    On Error Resume Next
    Err.Clear
    return_value = Application.WorksheetFunction.VLookup(lookup_value, _
                        range_lookup, col_index, error_value)
    'http://www.mrexcel.com/forum/excel-questions/644608-vlookup-where-number-stored-text.html
    'If number is stored as text
    'return_value=VLOOKUP(TEXT(A50,0),'COS recon'!A:C,2,0)
    If Err <> 0 Then
      return_value = error_value
    End If
    SafeVlookup = return_value
    On Error GoTo 0
End Function
In your Userform, copy this.
Code:
Private Sub cmdVLookUpinMultipleSheets_Click()
 Dim SrchRng As Range
 Dim SrchVal As Range
dim SrchPin as long
 Sheets("Sheet1").Select
 Range("A2").Select
 Set SrchVal = Cells(5, 1)    'value in Active Row 5 & Col 1
 Set SrchRng = Range("Sheet2!A2:A4")
 SrchPin = SafeVlookup(SrchVal, SrchRng, 3, False)
 MsgBox "SrchPin=" & SrchPin & "."
End Sub
Hope this helps.
 
Upvote 0
Hi pmich, it blocks over the above command on the words SafeVlookup "SrchPin = SafeVlookup(SrchVal, SrchRng, 3, False)"
My main point is that to create such macro so that to read information from another spreadsheet and especially the debtors groups which i separate them by codes e.g 5 names of debtors are belong code 10, other 7 names of debtors are belong the code 25 and so on. So then when i download the database and run the macro, should appears a message so that to enter the group code so that to mark the names of debtors whose are belong the code i entered and in addition each transaction which are belong the marked debtors names.For any additional information please do not hesitate to contact me. However many thanks for your respond. Best regards.
 
Upvote 0
SafeVlookup is a Function. I have given you the code for this Function, which I got from Net. Have you copied it in a Module?
If so, run the code in your UserForm and press the command button "cmdVLookUpinMultipleSheets".
It will trigger cmdVLookUpinMultipleSheets_Click.
This will store data in SrchVal from Cells(5, 1) of Sheet1 which is value in Row 5 & Col 1.
SrchVal is searched in the Range A2:A4 of Sheet2 and the result is displayed in a message box.
(Later on change the code manually or by using a DO LOOP to store in SrchVal some other value from Sheet1 to search in Sheet2.)
 
Upvote 0
Hi again pmich, something i am not do it right so the function dosen't work. I am sure that your instructions are correct but due to i am not so expert in VB is the reason that the function dosen't work. The fault is mine. Also i found that is complicate function and i don't want to discomfort you any more. I prefer to find the solution for my issue using the formula vlookup, which should search through other spreadsheet named "Groups" and so i think i will resolve my issue. This formula i will assing then to a macro command and the only manual work which i will do is just to enter the group's code in the cell "A1" in the database which i download. However great and many thanks for your help. Is very kind of you and i would appreciated to help so that to write in correct syntax the above formula. Best regards.
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

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