excel vba printpage are different values then on userform

evinx

New Member
Joined
Jun 16, 2018
Messages
15
hi all

when i print my userform listbox the values of 1 column change to a different value

can someone tell me what i did wrong ?
screenshot of what i want to print
http://prntscr.com/keph0g

code of printing
Code:
Private Sub OUprint1()
Me.Hide
Dim rng As Range, wks As Worksheet, ListData()
' define sheet name for the list output
Set wks = ThisWorkbook.Worksheets("OUprint")
' define range start for the list output
Set rng = wks.Range("A7")
If OU.ListCount = 0 Then
    MsgBox "There is nothing in the list to print!"
    Exit Sub
End If
ReDim ListData(OU.ListCount - 1, OU.ColumnCount - 1)
ListData() = OU.List()
wks.Cells.Clear
wks.Range("A1") = Klant.Caption
wks.Range("A2") = Adres.Caption
wks.Range("A3") = Postcode.Caption
wks.Range("A4") = Plaats.Caption
wks.Range("A6") = "Merk"
wks.Range("B6") = "Type"
wks.Range("C6") = "Serienr"
wks.Range("D6") = "Bouwjaar"
wks.Range("E6") = "Freon"
wks.Range("F6") = "KG"
wks.Range("G6") = "Ton Co2"
wks.Range("H6") = "Installatienr"
wks.Range("I6") = "Adres"
wks.Range("J6") = "Status"
wks.Range(rng, rng.Offset(UBound(ListData), 9)).Value = ListData()
Application.ScreenUpdating = False
wks.Visible = xlSheetVisible
wks.PageSetup.Orientation = xlLandscape
wks.Cells.HorizontalAlignment = -4131
wks.PrintPreview
wks.Visible = xlSheetVisible
Application.ScreenUpdating = True
wks.Cells.Clear
Application.Visible = False
Me.Show
End Sub

screenshot of print outcome
http://prntscr.com/kepi7b

as you can see the list "Ton co²" is different values on listbox it give me the right value 1,xx but on printpage it gaves me value 11.xx
 
Last edited:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
(solved)

Found it
code before
Code:
 If wsh.Cells(I, "C").Value = str3 Then
        'Just show value of mapping with column A
        .ColumnWidths = "30;75;100;60;40;50;40;100;35;50"
        .AddItem wsh.Cells(I, "E").Value
        .List(.ListCount - 1, 1) = wsh.Cells(I, "H").Value
        .List(.ListCount - 1, 2) = wsh.Cells(I, "I").Value
        .List(.ListCount - 1, 3) = wsh.Cells(I, "J").Value
        .List(.ListCount - 1, 4) = wsh.Cells(I, "L").Value
        .List(.ListCount - 1, 5) = wsh.Cells(I, "M").Value
        [COLOR=#ff0000].List(.ListCount - 1, 6) = wsh.Cells(I, "N").Value[/COLOR]
        .List(.ListCount - 1, 7) = wsh.Cells(I, "O").Value
        .List(.ListCount - 1, 8) = wsh.Cells(I, "P").Value
        .List(.ListCount - 1, 9) = wsh.Cells(I, "Q").Value

code after
Code:
 If wsh.Cells(I, "C").Value = str3 Then
        'Just show value of mapping with column A
        .ColumnWidths = "30;75;100;60;40;50;40;100;35;50"
        .AddItem wsh.Cells(I, "E").Value
        .List(.ListCount - 1, 1) = wsh.Cells(I, "H").Value
        .List(.ListCount - 1, 2) = wsh.Cells(I, "I").Value
        .List(.ListCount - 1, 3) = wsh.Cells(I, "J").Value
        .List(.ListCount - 1, 4) = wsh.Cells(I, "L").Value
        .List(.ListCount - 1, 5) = wsh.Cells(I, "M").Value
        [COLOR=#00ff00].List(.ListCount - 1, 6) = Format$(wsh.Cells(I, "N").Value, "0.00")[/COLOR]
        .List(.ListCount - 1, 7) = wsh.Cells(I, "O").Value
        .List(.ListCount - 1, 8) = wsh.Cells(I, "P").Value
        .List(.ListCount - 1, 9) = wsh.Cells(I, "Q").Value
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,189
Members
452,616
Latest member
intern444

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