Need to change image in userform on dropdown selection or next and prevoius button

Roampie

New Member
Joined
May 14, 2015
Messages
13
Hi

I would like to know how to get my userform to work correctly.

First my workbook contains 2 graphs which I would like to display in my userform using previous and next button.
At the moment it looks only like a static image and can't change between them.

I would also know how to put the ZAR (R) sign infront of the Label1, Label2 ect when I press the Get Data button.

See my code.

Userform1

Code:
[/B][/U][/COLOR]Private Sub CommandButton5_Click()
UserForm1.Hide
UserForm2.Show
End Sub


Private Sub UserForm_Initialize()


    Me.TextBox18.Text = CStr(ThisWorkbook.Sheets("Sheet1").Range("Q5").Value)
    Me.TextBox19.Text = CStr(ThisWorkbook.Sheets("Sheet1").Range("N9").Value)
    Me.TextBox29.Text = CStr(ThisWorkbook.Sheets("Sheet1").Range("P7").Value)
    
End Sub
Private Sub cmbDescription_Change()


    Me.txtCode.Text = Sheets("Database").Cells(cmbDescription.ListIndex + 2, Range("Code").Column).Value
    Me.TextBox23.Text = Sheets("Database").Cells(cmbDescription.ListIndex + 2, Range("Pakage").Column).Value
    Me.txtPrice.Text = Sheets("Database").Cells(cmbDescription.ListIndex + 2, Range("Price").Column).Value
    
End Sub
Private Sub TextBox22_Change()


    If Me.TextBox22.Text <> "" Then
        Me.txtPrice.Value = Me.TextBox22.Value * Sheets("Database").Cells(cmbDescription.ListIndex + 2, Range("Price").Column).Value
    Else
        Me.txtPrice.Text = 0
    End If
    
End Sub
Private Sub CommandButton1_Click()




'---------------------Inv nr. & Inv Total-------------------------




With Sheet1
    
    Sheets("Sheet1").Range("Q5") = TextBox18.Value
    Sheets("Sheet1").Range("N9") = TextBox19.Value
    Sheets("Sheet1").Range("P7") = TextBox29.Value
        
End With




'--------------------Consumables-----------------------------------




With Sheet1
     eRow = Range("A1").End(xlDown).Offset(1, 0).Row
    .Cells(eRow, "A").Value = TextBox1.Text
    .Cells(eRow, "B").Value = ComboBox1.Text
    .Cells(eRow, "C").Value = TextBox3.Text
    .Cells(eRow, "D").Value = TextBox4.Text
    .Cells(eRow, "E").Value = TextBox21.Text
    .Cells(eRow, "F").Value = TextBox5.Text


'--------------------------------Paint & Material--------------------




     eRow = Range("A27").End(xlDown).Offset(1, 0).Row
     .Cells(eRow, "A").Value = TextBox6.Text
     .Cells(eRow, "B").Value = cmbSupplier.Value
     .Cells(eRow, "C").Value = TextBox8.Value
     .Cells(eRow, "D").Value = cmbDescription.Value
     .Cells(eRow, "F").Value = txtCode.Value
     .Cells(eRow, "G").Value = TextBox24.Value
     .Cells(eRow, "H").Value = TextBox23.Value
     .Cells(eRow, "E").Value = TextBox22.Value
     .Cells(eRow, "I").Value = txtPrice.Value
     
     
             
'----------------------------Equipment Hire-----------------------
        
      eRow = Range("K35").End(xlDown).Offset(1, 0).Row
      .Cells(eRow, "K").Value = TextBox25.Text
      .Cells(eRow, "L").Value = TextBox26.Value
      .Cells(eRow, "M").Value = TextBox27.Value
      .Cells(eRow, "N").Value = TextBox28.Value
        
'-------------------------------Labour----------------------------
        
      eRow = Range("A46").End(xlDown).Offset(1, 0).Row
      .Cells(eRow, "A").Value = TextBox11.Text
      .Cells(eRow, "B").Value = TextBox12.Value
      .Cells(eRow, "C").Value = TextBox13.Value
              
        
'-------------------------------Transport-------------------------




      eRow = Range("K16").End(xlDown).Offset(1, 0).Row
      .Cells(eRow, "K").Value = TextBox16.Text
      .Cells(eRow, "L").Value = TextBox17.Value
      .Cells(eRow, "M").Value = TextBox20.Value
      
End With








'--------------------------Clear input controls-------------------




        Me.TextBox1.Text = ""
        Me.ComboBox1.Text = ""
        Me.TextBox3.Text = ""
        Me.TextBox4.Text = ""
        Me.TextBox21.Text = ""
        Me.TextBox5.Text = ""
        Me.TextBox6.Text = ""
        Me.cmbSupplier.Text = ""
        Me.TextBox8.Text = ""
        Me.cmbDescription.Text = ""
        Me.txtCode.Text = ""
        Me.TextBox24.Text = ""
        Me.TextBox23.Text = ""
        Me.TextBox22.Text = ""
        Me.txtPrice.Text = ""
        Me.TextBox11.Text = ""
        Me.TextBox12.Text = ""
        Me.TextBox13.Text = ""
        Me.TextBox16.Text = ""
        Me.TextBox17.Text = ""
        Me.TextBox20.Text = ""
        Me.TextBox25.Text = ""
        Me.TextBox26.Text = ""
        Me.TextBox27.Text = ""
        Me.TextBox28.Text = ""
            
        
 '----------------------------------------------------------------
   
   
   ActiveWorkbook.Save


   UserForm1.TextBox1.SetFocus




End Sub
Private Sub CommandButton2_Click()


Dim didSave As Boolean
    Me.Hide
    didSave = Application.Dialogs(xlDialogSaveAs).Show
    Me.Show
    
End Sub
Private Sub CommandButton4_Click()


Application.Visible = True
Unload Me


End Sub


[COLOR=#333333][U][B]


Userform2

Code:
[/B][/U][/COLOR]Private Sub cmdLoad_Click()


End Sub
Private Sub CommandButton1_Click()


UserForm2.Hide
UserForm1.Show


End Sub


Private Sub CommandButton2_Click()


'Print only "Sheet2"
Sheets("Reports").PrintOut




End Sub
Private Sub CommandButton5_Click()
 
Label1.Caption = Sheets("Reports").Range("B7")
Label2.Caption = Sheets("Reports").Range("B8")
Label3.Caption = Sheets("Reports").Range("B9")
Label4.Caption = Sheets("Reports").Range("B10")
Label5.Caption = Sheets("Reports").Range("B11")
Label6.Caption = Sheets("Reports").Range("B12")
Label7.Caption = Sheets("Reports").Range("B13")
Label8.Caption = Sheets("Reports").Range("B14")
Label9.Caption = Sheets("Reports").Range("B15")
Label10.Caption = Sheets("Reports").Range("B16")
Label11.Caption = Sheets("Reports").Range("B17")
Label12.Caption = Sheets("Reports").Range("B18")
Label13.Caption = Sheets("Reports").Range("B19")
Label14.Caption = Sheets("Reports").Range("B20")
Label29.Caption = Sheets("Reports").Range("A5")


End Sub
Private Sub UserForm_Initialize()


ComboBox1.AddItem ("Site Expense")
ComboBox1.AddItem ("Materials & Labour")


    Dim Fname As String


    Call SaveChart
    Fname = ThisWorkbook.Path & "\temp1.gif"
    Me.Image1.Picture = LoadPicture(Fname)
End Sub


Private Sub SaveChart()
    Dim MyChart As Chart
    Dim Fname As String


    Set MyChart = Sheets("Reports").ChartObjects(1).Chart
    Fname = ThisWorkbook.Path & "\temp1.gif"
    MyChart.Export Filename:=Fname, FilterName:="GIF"
End Sub


[COLOR=#333333][U][B]
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,215,416
Messages
6,124,774
Members
449,187
Latest member
hermansoa

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