My question, what is the Vba code
(Excel version 2007)
I want vba code for customer address in range (E11:E18)
At this moment he stopt at the last not empty cell in kolumn "E" , cell "E47"
See my file
Thanks for help
My question, what is the Vba code
(Excel version 2007)
I want vba code for customer address in range (E11:E18)
At this moment he stopt at the last not empty cell in kolumn "E" , cell "E47"
See my file
Thanks for help
For this task you don't need VBA. But you do need a proper database design for your Sheet2. I have arranged the sheet for you. Please look at the attached workbook.
You will see that all data are in the range A2:I4. The formula below makes this address dynamic, meaning, as you add more customer numbers the range grows automatically. I used this formula to define the range I named "Customers".
=OFFSET(Sheet2!$A$2,0,0,COUNTA(Sheet2!$A:$A)-1,COUNTA(Sheet2!$1:$1))
Explainer: Start at Sheet2!A2, move 0 rows down and 0 columns to the right and then extend the selection down by as many entries as there are in column A not counting 1 caption column, and as many columns to the right as there are entries in row 1. So, don't leave any blanks in row 1 or column A.
Now you can access your data with a simple VLookup. To save you the time of typing the customer number in H9 of your Sheet1, and to avoid any possibility of typos in that process, select the customer form a drop-down list. In the attached workbook I created such a drop-down for you. Observe the formula for setting the list.
=INDEX(Customers,,1)
The list is created from the same named range as I set up for the data, just using the first column of it. Therefore this list inherits its dynamism from the Customers named range.
Now that all preparations are done you can construct the VLookup formula in Sheet1!E11. Here it is.
=VLOOKUP($H$9,Customers,ROW()-9, FALSE)
Explainer: Look for the value in H9 in the first column of the range "Customers". When found, go as many columns to the right as of this row's number (that is 11 in E11), minus 9. 11-9 = 2, and return the value found there. As you copy this formula down, ROW() increases. So the formula will work out to 12-9, 13-9, 14-9 etc, enumerating the columns in your customer table.
Talking of tables, you should consider using a table for your DB on Sheet2. I didn't want to add one more straw to this load, but it'll be easier to manage going forward if you make such a change.