Concatenate or Join values based on Input box and related cell value

KCOOK1276

New Member
Joined
Nov 6, 2009
Messages
5
I am trying to assign a unique number to each row composed of 4 data elements provided via input box and a portion of an existing value in a related cell. I have tried a couple of different options and keep hitting a wall. The string below is long but I hit a snag towards the bottom in green where i have two formulas both attempting to preform the same action.

Sub Voucher_Number()
'
' Voucher_Number Macro
' Insert column and concatenate
'
' Keyboard Shortcut: Ctrl+v
'
Dim DW As Worksheet
Set DW = Worksheets("RM_FMP Washington (2)")

DW.Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

DW.Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

DW.Range("A1").FormulaR1C1 = "Voucher Number"
DW.Range("B1").FormulaR1C1 = "Document Type"

Dim DocumentType As Range
Dim VoucherNumber As Range
Dim LastROW As Long
Dim Analyst As String
Dim FM As String
Dim Allotment As String
Dim FY As String
Dim ROW As Integer


LastROW = DW.Cells(DW.Rows.Count, "C").End(xlUp).ROW

Set DocumentType = DW.Range(Cells(2, 2), Cells(LastROW, 2))
Set VoucherNumber = DW.Range(Cells(2, 1), Cells(LastROW, 1))


Analyst = Application.InputBox("Please provide first initial of the last name of the analyst processing of the Collections?") 'memory for a text string
FM = Application.InputBox("Please provide Letter representing the fiscal month of the collections?") 'memory for text string
Allotment = Application.InputBox("Provide the Cost Center Allotment Number") 'memory for text string
FY = Application.InputBox("Provide the Collection Fiscal Year") 'memory for text string



DocumentType.FormulaR1C1 = "=IF(Left(RC[2],2)=""19"",IF(LEFT(RC[3],2)=""10"",""IV"",IF(LEFT(RC[3],2)=""20"",""IV"",IF(LEFT(RC[3],2)=""30"",""IV"",IF(LEFT(RC[3],2)=""60"",""IV"",IF(LEFT(RC[3],1)=""8"",""IV"",IF(LEFT(RC[3],1)=""A"",""IV"",IF(LEFT(RC[3],2)=""17"",""IV"",""DW""))))))),""OA"")"

DocumentType.Copy
DocumentType.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False



ActiveCell.Select= Allotment &FM &FY &Analyst &Text(Right(RC[2],4),""@"")


VoucherNumber.FormulaR1C1 = Concatenate(Application.InputBox(""Provide the Cost Center Allotment Number?""),Application.InputBox(""Please provide Letter representing the fiscal month of the collections?""),Application.InputBox(""Provide the Collection Fiscal Year""),Application.InputBox(""Please provide first initial of the last name of the analyst processing of the Collections?""),Text(Right(RC[2],4),""@""))"




'VoucherNumber.FormulaR1C1 = _
"=IF(RC[1]=""DW"",CONCATENATE(""8724"",IF(MONTH(NOW())=1,""A"",IF(MONTH(NOW())=2,""B"",IF(MONTH(NOW())=3, ""C"",IF(MONTH(NOW())=4,""D"",IF(MONTH(NOW())=5,""E"",IF(MONTH(NOW())=6,""F"",IF(MONTH(NOW())=7,""G"",IF(MONTH(NOW())=8,""H"",IF(MONTH(NOW())=9,""I"",IF(MONTH(NOW())=10,""J"",IF(MONTH(NOW())=11,""K"",IF(MONTH(NOW())=12,""L"","" "")))))))))))),RIGHT(LEFT(RC[1],2),1),""W"",RIGHT(RC[1],4)),IF(RC[1]=IV, CONCATENATE(""8724"",IF(MONTH(NOW())=1,""A"",IF(MONTH(NOW())=2,""B"",IF(MONTH(NOW())=3, ""C"",IF(MONTH(NOW())=4,""D"",IF(MONTH(NOW())=5,""E"",IF(MONTH(NOW())=6,""F"",IF(MONTH(NOW())=7,""G"",IF(MONTH(NOW())=8,""H"",IF(MONTH(NOW())=9,""I"",IF(MONTH(NOW())=10,""J"",IF(MONTH(NOW())=11,""K"",IF(MONTH(NOW())=12,""L"","" "")))))))))))),RIGHT(LEFT(RC[1],2),1),""W"",RIGHT(RC[1],4))"

'CopyPasteValueVN Macro

'VoucherNumber.Copy
'VoucherNumber.Select
'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False



End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,223,630
Messages
6,173,454
Members
452,514
Latest member
cjkelly15

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