Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Condensing VBA code Brad Excel Discussion (Misc queries) 3 September 9th 09 05:51 PM
Need help condensing with-end with code excelnut1954 Excel Programming 2 May 1st 06 03:49 PM
Trouble Condensing Code Ikaabod Excel Programming 3 April 11th 06 09:53 PM
Condensing my worksheet Derek Witcher Excel Worksheet Functions 4 September 1st 05 03:59 PM
1.)Input Boxes 2.) Condensing a Code David W[_3_] Excel Programming 2 July 17th 03 11:51 PM


All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"