Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Condensing Code
I need help passing variables to another sub routine.
Below I have included a piece of code that would need to be repeated 12 times. Let me know if i have to clarify anything! The following items would have to be "swapped" out each time: tbBlackASection1Weight tbBlackASection1Description BlackAContractPricePerPound BlackAContractPrice If QuoteBreakDown.tbBlackASection1Weight.Value < "" Then QuoteForm.Range("A" & DataRow).Value = "Black Uncoated " & QuoteBreakDown.tbBlackASection1Description.Text If Wizard.obShowWeights = True Then QuoteForm.Range("E" & DataRow).Value = "Approximately" With QuoteForm.Range("G" & DataRow) .Value = ThisWorkbook.Worksheets("Calculations").Range("Bla ckASection1Weight").Text & " lbs @ " .HorizontalAlignment = xlRight End With End If If Wizard.obUnit = True Then With QuoteForm.Range("H" & DataRow) .Value = "$" & Format(ThisWorkbook.Worksheets("Calculations").Ran ge("BlackAContractPricePerPound").Value * 100, "##.#0") & " / cwt" .HorizontalAlignment = xlRight End With End If If Wizard.obLump = True Then With QuoteForm.Range("H" & DataRow) .Value = "$" & ThisWorkbook.Worksheets("Calculations").Range("Bla ckAContractPrice").Value .HorizontalAlignment = xlRight End With End If DataRow = DataRow + 1 End If |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Condensing Code
Assume BlackA is the variable part.
Sub CalcSomething(aaa as String) If QuoteBreakDown.controls( _ "tb" & aaa & "Section1Weight").Value < "" Then QuoteForm.Range("A" & DataRow).Value = _ "Black Uncoated " & QuoteBreakDown _ .Controls("tb" & aaa & _ "Section1Description").Text If Wizard.obShowWeights = True Then QuoteForm.Range("E" & DataRow).Value = "Approximately" With QuoteForm.Range("G" & DataRow).Value = _ ThisWorkbook.Worksheets("Calculations") _ .Range(aaa & "Section1Weight").Text & _ " lbs @ " .HorizontalAlignment = xlRight End With End If If Wizard.obUnit = True Then With QuoteForm.Range("H" & DataRow).Value = "$" & _ Format(ThisWorkbook.Worksheets("Calculations") _ .Range(aaa & "ContractPricePerPound") _ .Value * 100, "##.#0") & " / cwt" .HorizontalAlignment = xlRight End With End If If Wizard.obLump = True Then With QuoteForm.Range("H" & DataRow).Value = "$" & _ ThisWorkbook.Worksheets("Calculations") _ .Range(aaa & "ContractPrice").Value .HorizontalAlignment = xlRight End With End If DataRow = DataRow + 1 End If End Sub -- Regards. Tom Ogilvy "steve" wrote: I need help passing variables to another sub routine. Below I have included a piece of code that would need to be repeated 12 times. Let me know if i have to clarify anything! The following items would have to be "swapped" out each time: tbBlackASection1Weight tbBlackASection1Description BlackAContractPricePerPound BlackAContractPrice If QuoteBreakDown.tbBlackASection1Weight.Value < "" Then QuoteForm.Range("A" & DataRow).Value = "Black Uncoated " & QuoteBreakDown.tbBlackASection1Description.Text If Wizard.obShowWeights = True Then QuoteForm.Range("E" & DataRow).Value = "Approximately" With QuoteForm.Range("G" & DataRow) .Value = ThisWorkbook.Worksheets("Calculations").Range("Bla ckASection1Weight").Text & " lbs @ " .HorizontalAlignment = xlRight End With End If If Wizard.obUnit = True Then With QuoteForm.Range("H" & DataRow) .Value = "$" & Format(ThisWorkbook.Worksheets("Calculations").Ran ge("BlackAContractPricePerPound").Value * 100, "##.#0") & " / cwt" .HorizontalAlignment = xlRight End With End If If Wizard.obLump = True Then With QuoteForm.Range("H" & DataRow) .Value = "$" & ThisWorkbook.Worksheets("Calculations").Range("Bla ckAContractPrice").Value .HorizontalAlignment = xlRight End With End If DataRow = DataRow + 1 End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Condensing VBA code | Excel Discussion (Misc queries) | |||
Need help condensing with-end with code | Excel Programming | |||
Trouble Condensing Code | Excel Programming | |||
Condensing my worksheet | Excel Worksheet Functions | |||
1.)Input Boxes 2.) Condensing a Code | Excel Programming |