Improving a printing code - help needed!

BELFRED6

Board Regular
Joined
Oct 31, 2008
Messages
110
Hello,

In order to print invoices based on the result of a dropdown list, I am using the following code:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> </o:p>
Sub Print_Invoice()

Dim rCell As Range

With ActiveSheet <o:p></o:p>

ForEach rCell In .Range("A2:A10")
.Range("J3").Value = rCell.Value: Calculate
If .Range("P14").Value > 0 Then .PrintOut
Next rCell
EndWith

EndSub

On my invoice form appears the name of the deliverer in cell H3. I am trying to refine the code above to print out invoices in the ALPHABETICAL order of the H3 cell content. <o:p></o:p>

<o:p> </o:p>
I found in that forum the code below to sort the printing order but since I am a VBA novice, I have no idea what to do with that code… Can you help?

<o:p></o:p>

Private Sub VSortMA(ary, LB, UB, ref)
Dim M As Variant, i As Long, ii As Long, iii As Long
i = UB: ii = LB
M = ary(Int((LB + UB) / 2), ref)
Do While ii <= i
Do While ary(ii, ref) < M
ii = ii + 1
Loop
Do While ary(i, ref) > M
i = i - 1
Loop
If ii <= i Then
For iii = LBound(ary, 2) To UBound(ary, 2)
temp = ary(ii, iii): ary(ii, iii) = ary(i, iii): ary(i, iii) = temp
Next
ii = ii + 1: i = i - 1
End If
Loop
If LB < i Then VSortMA ary, LB, i, ref
If ii < UB Then VSortMA ary, ii, UB, ref
End Sub <o:p></o:p>
<o:p> </o:p>
<?xml:namespace prefix = st1 /><st1:place></st1:place><st1:place></st1:place><st1:place></st1:place><!-- / message -->
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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