Excel - Multiline Textbox offset each line onto the next column? - excel

I need some Excel help here.
I am trying to create a database to store customers information in my shop.
The customer will have a name and address, something like this:
MR SMITH
123 FLAT A, 321 ROAD,
LONDON,
AB12 3AB
UNITED KINGDOM
This address has 5 rows. I want to just copy and paste everything into my userform which has a Multiline Textbox. I need it to offset each row into each column of my spreadsheet.
So it ends up looking like this:
CELL A1 = MR SMITH
CELL B1 = 123 FLAT A, 321 ROAD,
CELL C1 = LONDON,
CELL D1 = AB12 3AB
CELL E1 = UNITED KINGDOM
I know I can create a 5 single line Textboxes in my userform, but I want to save time by copying everything into 1 Textbox instead of 5.
Please help.
Thanks!

The data I have stored in the cell H5, but you can use a Var or a Textbox like source...
If you want to save in the cells, use:
Range("A1:E1").Value = Split(Range("H5").Value, Chr(10))
if you want an array to manipulate (put value in separate Textbox), use
myarr = Split(Range("H5").Value, Chr(10))

Related

How to generate invoice numbers with a combination of customer codes without duplicates and sequentially with VBA

Dear All Master,
How to generate invoice numbers with a combination of customer codes without duplicates and sequentially with VBA.
so the position in "C2" is the customer code.
So the "serial" will change continuously in order with the customer code. Does it need invoice numbers stored in their own sheets so that they make it easier for duplicates and sequential to occur? if necessary how?. Please recommend the best solution
in "C4" is the combination invoice number.
JS : COMPANY NAME
12 : MONTH
22 : 2 DIGIT YEAR
XX : CUSTOMER CODE
001 : SERIAL
EXAMPLE
JS-12-22-10-001
JS-12-22-10-002
JS-12-22-11-001
JS-12-22-11-002
Sub generatenumberinvoice()
Sheet1.Range("c3").Value = Sheet1.Range("c3").Value + 1
End Sub
This is not directly help you, but maybe you can have a look and modify it according to your case.
Make a new workbook
Rename Sheet1 into TABLE, Sheet2 into DATA, Sheet3 into FormInput
Type on each sheet exactly like in the picture below. For the time being, ignore the INPUT button which seen in the image of sheet FormInput
In the Name Manager, create a named range CustID which refers to:=OFFSET(TABLE!$A$1,0,0,COUNTA(TABLE!$A:$A),2)
Create another named range : data which refers to: =OFFSET(DATA!$A$1,0,0,COUNTA(DATA!$A:$A),4)
Create another named range : trans which refers to : =OFFSET(FormInput!$A$6,0,0,COUNTA(FormInput!$A:$A)-4,1)
Finally, copy the formula below and paste it to cell B3 of sheet FormInput =IF(COUNTIF(INDEX(data,,3),"*JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"*")<>0,"JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"-"&TEXT(AGGREGATE(14,6,RIGHT(INDEX(data,,3),3)/(LEFT(INDEX(data,,3),12)="JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"-"),1)+1,"000"),"JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"-001")
Try to type aaa (the name of customer) in cell B2 sheet FormInput. If everything above done correctly, cell B3 will show JS-22-12-10-001. Type bbb then it show JS-22-12-11-001, type ccc then it show JS-22-12-12-001. The last 3 characters always show 001 (which means this is the first invoice number of Dec-22 for whatever id), because there is no data in sheet DATA. Hence it just show 22-12 depends on the date seen in cell B1, and -10 or -11 or -12 depends on the name of the customer seen in cell B2.
Try to change the date to something like 21-nov-22. Cell B3 will show 22-11 and the CustID depends on the name seen in cell B2, and the number always show "001". Play around by changing the date of different month and change the name (aaa or bbb or ccc) so you understand thoroughly how it works.
Now, fill data in sheets DATA exactly like the image below
Back in FormInput, fill the date with Nov-22 month and fill the cust name with aaa, cell B3 will show the next invoice number: JS-22-11-10-006 because the formula read the data that the last number for id 10 in Nov-22 is JS-22-11-10-005, so the formula add 1 to the serial number in cell B3 for id 10 (customer aaa in this case).
Still in November date, type bbb for cust name. It will show JS-22-11-11-001 in cell B3 because there is no data for id 11 of Nov-22. So this is the first invoice number of Nov-22 for id 11 (customer bbb in this case).
Now change the date to December date, then type aaa for cust name. Cell B3 will show the next invoice number for id 10 in Dec-22 is JS-22-12-10-002, because the formula see that the last number in the data for id 10 of Dec-22 is "001".
Still in December date,
type ccc for cust name. Cell B3 will show JS-22-12-12-004.
type bbb for cust name. Cell B3 will show JS-22-12-11-001 which means this is the first invoice number for id 11 in Dec-22.
Play around by filling a different invoice number in sheet DATA then fill the date and the name of the cust in sheet InputForm.
The INPUT button seen in InputForm is a vba code to input the data seen in InputForm into sheet DATA. But this is another case, and if you want to know it, I think you'd better open another question.
Thank you.
Thanks to Mr. Peter_SSs, because I get the formula for cell B3 from him in this link

Selecting rows of a table from a column of another table

I have a column in "table1.xlsx" with more than 200 IDs.
ID
21321
54646
48949
...
And another "table2.xlsx" with the IDs plus all the information about the people.
Name Surname ID City
John Wayne 54646 Madrid
Mary Jane 11111 Berlin
Julius Randle 21321 Rome
Peter Parker 48949 New York
I would like to extract the rows from "table2" that match with the IDs from "table1". There is an easy way?
"table3.xlsx"
Name Surname ID City
John Wayne 54646 Madrid
Julius Randle 21321 Rome
Peter Parker 48949 New York
Open table1.xlsx, table2.xlsx and table3.xlsx in Excel.
Go to Table1.xlsx. Select column A by clicking on A. Above that Column, you will see a box where cell number typically shows up. Click inside that and type in MyIDs.
Go to table2.xlsx. Create a new field called Matching IDs like so:
In Cell E2, type the formula:
=VLOOKUP(C2, table1.xlsx!MyIDs, 1, FALSE)
Hit enter. This formula means, take C2 (from table2) and find a matching row in table1.xlsx's named table called MyIDs (which is column A of table1). Then, choose the 1st column (which is the only column) from MyIDs. FALSE means do an exact match not an approximate match.
Click on E2. Copy it. Paste it into E3..En. You can drag to copy as well. That'll populate the formula in each cell in E column like this:
Click on sort and filter like this:
Click on Matching IDs dropdown and de-select #N/A
Highlight all rows and cells from the filtered data like so:
Copy. Go to table3.xlsx. Paste. Remove the extra column called Matching IDs at the end in table3.xlsx

Excel Index Partial match

I have Sheet1 with column A listing every single country in alphabetical order..
A
1 Afghanistan<
2 Albania
3 Algeria
4 American Samoa
5 Andorra
----------
228 United Kingdom
229 United States
etc
I have Sheet2 column A with empty cells with adjacent cells in column B listing address details
A B
1 empty cell Unit 3, Road;London, United Kingdom
2 empty cell Building 1, Road, TX, United States
3 empty cell 8th floor, Business Park, India 1234
etc
What I would like to know is how can I obtain the country within the address details in sheet2 column B and place them in Sheet2 column A, based on a match on the list of countries in Sheet1 column A.
Part of the problem is there is no coherent method as to how to country is placed within the address; could be at the end or in the middle of the address.
I have tried various index match formulas with no luck
any help would be appreciated.
I tried it with the reference table being in A1:B7, and lookups being A10:B10 onwards down. The formula is for these cells. You can adjust it for Sheet1/2!.
Assuming your data is in B10 onwards, and your reference data was in B1:B7, you can write this formula in A10 =INDEX($B$1:$B$7,MAX(IF(ISERROR(FIND($B$1:$B$7,B10)),-1,1)*(ROW($B$1:$B$7)-ROW($B$1)+1))). This is an array formula, so please hit Ctrl+Shift+Enter for excel to read it as an array formula.
(In the screenshot, I have pasted the table in A10:B12 as values only in D10:E12)
Text to Columns with a comma delimiter

Excel - fill in cell basd on cells enters on worksheet but only fill

I have an excel sheet that has a sheet that our sales team have to fill in. There are 31 rows and column d may have the same text in multiple lines.
I need then to take all the text from column d and have it automatically sum the total from each text in d.
Column d is a dropdown list.
I don't want it to automatically go line from line, for example,
the data entered is:
9/12/15 ABC Store $10.00
9/13/15 DEF Store $15.00
9/14/15 ABC Store $5.00
9/16/15 DEF Store $50.00
I need it to automatically, as they enter the data to do the following on a different sheet.
A1= ABC Store B1= $15.00
A2= DEF Store B2= $65.00
etc. The data they choose as the enter may vary per month so I need it to understand to pick what is entered and then combine those totals if that text is choose between rows 5:31.
I really appreciate anyone's help.
Try to use the =SUMIF()-formula. See example below.

create a excel search engine using vba and filters

I am trying to create a search engine using vba to filter my rows based on a value entered into a cell/my search bar.
Sub DateFilter()
'hide dialogs
Application.ScreenUpdating = False
'filter for records that have June 11, 2012 in column 3
ActiveSheet.Range("A5:C30").AutoFilter Field:=3, Criteria1:=ActiveSheet.Range("A5").Value
Application.ScreenUpdating = True
End Sub
This macro runs when a user hits my search button and will filter my rows based on the cell value in my cell A5.
However whilst the code is filtering it is showing the wrong result.
I have the following layout in excel:
A B C
White XXX London
Black ZZZ Manchester
Gold TTT England
Silver FFFF Scotland
If I type in my cell A5 the word White it will show silver?
Can someone please show me where I am going wrong? Thanks
As Gary's Student commented, you're currently filtering your rows based on a cell value inside your rows.
Instead of this, filter it based on a value outside, like D1. Then you can put whatever you like into the D1 cell for your filter.

Resources