Dummy Excel
Well-known Member
- Joined
- Sep 21, 2005
- Messages
- 1,004
- Office Version
- 2019
- 2010
- 2007
- Platform
- Windows
I have some data where row 1 is my header row, then row 2 is my store number and then i have the following rows are the purchase orders for that month. This number of rows can change each month. Then straight after that I have my next store number, and then again i have the following rows as the purchase
orders for that month, This number can change each month.
Im trying to concatenate the store number with the purchase order number to be like this xxx-xxxxx-D.
my formula is
the problem I have is when I get to the next store number it still shows cell A2 as I have made it an absolute
reference.
My code so far is below, if there is an easier or quicker way please let me know
here is an example of my spreadsheet
so 117, 416, 432, 435 are all store numbers and 3917 is a purchase order for example. So what I need is 117-03917-D - the purchase order needs to be 5 digits long. All the * are blank cells.
Any help will be greatly appreciated
thanks
Sam
orders for that month, This number can change each month.
Im trying to concatenate the store number with the purchase order number to be like this xxx-xxxxx-D.
my formula is
Code:
"=IF(LEN(RC[-1])=4, R2C1&""-0""&RC[-1]&""-D"", R2C1&""-""&RC[-1]&""-D"")"
the problem I have is when I get to the next store number it still shows cell A2 as I have made it an absolute
reference.
My code so far is below, if there is an easier or quicker way please let me know
Code:
Sub Macro1()
Columns("B:B").Insert Shift:=xlToRight
Range("B3").FormulaR1C1 = _
"=IF(LEN(RC[-1])=4, R2C1&""-0""&RC[-1]&""-D"", R2C1&""-""&RC[-1]&""-D"")"
Range("B3").Copy
Range("C3").End(xlDown).Offset(0, -1).Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.End(xlDown).Offset(2, 0).FormulaR1C1 = _
"=IF(LEN(RC[-1])=4, R2C1&""-0""&RC[-1]&""-D"", R2C1&""-""&RC[-1]&""-D"")"
end sub
here is an example of my spreadsheet
Excel Workbook | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | PO # | ORIGINAL ORDER QUANTITY | EFFECTIVE ORDER QUANTITY | QUANTITY ON TIME | ||
2 | 117 | * | * | * | ||
3 | 3917 | 1686 | 1686 | 0 | ||
4 | 6747 | 762 | 762 | 762 | ||
5 | 416 | * | * | * | ||
6 | 54335 | 1785 | 1785 | 1755 | ||
7 | 54406 | 876 | 876 | 0 | ||
8 | 54640 | 1068 | 1068 | 0 | ||
9 | 54641 | 924 | 924 | 0 | ||
10 | 54666 | 267 | 267 | 0 | ||
11 | 432 | * | * | * | ||
12 | 12932 | 2415 | 2415 | 2415 | ||
13 | 435 | * | * | * | ||
14 | 28552 | 4116 | 4116 | 4116 | ||
15 | 38513 | 2179 | 2179 | 1185 | ||
PO Summary |
so 117, 416, 432, 435 are all store numbers and 3917 is a purchase order for example. So what I need is 117-03917-D - the purchase order needs to be 5 digits long. All the * are blank cells.
Any help will be greatly appreciated
thanks
Sam