اذهب الي المحتوي
أوفيسنا

الردود الموصى بها

قام بنشر

اريد كود تغيير  مصدر  الشيت vlookup  للظهور  فى اليوزر فورم


Private Sub ComboBox1_Change()
On Error Resume Next
If ComboBox2.MatchFound = False Then MsgBox "اختر من القائمة": Exit Sub
lr = ورقة1.Cells(Rows.Count, "A").End(xlUp).Row
 Dim a As Range
 Set ww = Application.WorksheetFunction
 Set a = ورقة1.Range("A2:z" & lr)
Me.TextBox2.Value = ww.VLookup(Me.ComboBox2.Value, a, 2, False)
Me.TextBox3.Value = ww.VLookup(Me.ComboBox2.Value, a, 3, False)
Me.TextBox4.Value = ww.VLookup(Me.ComboBox2.Value, a, 4, False)
Me.TextBox5.Value = ww.VLookup(Me.ComboBox2.Value, a, 5, False)
Me.TextBox6.Value = ww.VLookup(Me.ComboBox2.Value, a, 9, False)
Me.TextBox7.Value = ww.VLookup(Me.ComboBox2.Value, a, 10, False)
Me.TextBox8.Value = ww.VLookup(Me.ComboBox2.Value, a, 7, False)
Me.TextBox9.Value = ww.VLookup(Me.ComboBox2.Value, a, 8, False)
Me.TextBox10.Value = ww.VLookup(Me.ComboBox2.Value, a, 11, False)
Me.TextBox11.Value = ww.VLookup(Me.ComboBox2.Value, a, 13, False)
Me.TextBox12.Value = ww.VLookup(Me.ComboBox2.Value, a, 26, False)
Me.Image1.Picture = LoadPicture(TextBox12.Value)
Me.TextBox13.Value = ww.VLookup(Me.ComboBox2.Value, a, 12, False)
End Sub

 

اريد عند تغيير  الشيت عن طريق OptionButton  يتغير


lr = ورقة1.Cells(Rows.Count, "A").End(xlUp).Row
 Dim a As Range
 Set ww = Application.WorksheetFunction
 Set a = ورقة1.Range("A2:z" & lr)

لتكون ورقة 2   او ورقة3

قام بنشر

اخى الفاضل

اولا لك منى دعوه طيبه للالتزام بقواعد المنتدى

ومنها ان تكون اسماء الظهور باللغه العربيه

..............................................................

ثانيا هذه محاوله بسيطه منى

ارجو ان تفى بالغرض

تقبل تحياتى


Private Sub CommandButton2_Click()
Application.Visible = True
searchE.Hide
End Sub

Private Sub CommandButton4_Click()
Me.PrintForm
End Sub

Private Sub CommandButton5_Click()
searchE.Hide
Main.Show

End Sub

Private Sub Label5_Click()

End Sub

Private Sub OptionButton1_Click()
    OptionChange (1)
    
End Sub

Private Sub OptionButton2_Click()
    OptionChange (2)
    
End Sub

Private Sub OptionButton3_Click()
    OptionChange (3)
    
End Sub

Sub OptionChange(myOption As Long)
Me.ComboBox2.Clear
For h = 2 To 9
Me.Controls("textbox" & h).Value = ""
Next
    Select Case myOption
    Case 1
        With Sheets("qs")
        .Select
            ComboBox2.List = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Value
        End With
    Case 2
        With Sheets("q")
                .Select

            ComboBox2.List = .Range("A2:A" & .Cells(Rows.Count, "C").End(xlUp).Row).Value
        End With
    Case 3
        With Sheets("gar")
                .Select

            ComboBox2.List = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Value
        End With
   Case 4
        With Sheets("dok")
                .Select

            ComboBox2.List = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Value
        End With
    Case 5
        With Sheets("harrr")
                .Select

            ComboBox2.List = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Value
        End With
    Case 6
        With Sheets("owww")
                .Select

            ComboBox2.List = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Value
        End With
    Case 7
        With Sheets("baaaa")
            ComboBox2.List = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Value
        End With
    Case 8
        With Sheets("bbbbb")
            ComboBox2.List = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Value
        End With
     Case 9
        With Sheets("qqqq")
                .Select

            ComboBox2.List = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Value
        End With
    End Select
End Sub

Private Sub OptionButton4_Click()
OptionChange (4)

End Sub

Private Sub OptionButton5_Click()
OptionChange (5)

End Sub

Private Sub OptionButton6_Click()
OptionChange (6)

End Sub

Private Sub OptionButton7_Click()
OptionChange (7)

End Sub

Private Sub OptionButton8_Click()
OptionChange (8)

End Sub

Private Sub OptionButton9_Click()
OptionChange (9)

End Sub
Private Sub TextBox8_Change()
TextBox8.Value = Format(TextBox8.Value, "yyyy/mm/dd")
End Sub

Private Sub TextBox9_Change()
TextBox9.Value = Format(TextBox9.Value, "yyyy/mm/dd")
End Sub

Private Sub ComboBox2_Change()
On Error Resume Next
If ComboBox2.MatchFound = False Then MsgBox "ÝÖáÇ ÇÎÊÑ ãä ÇáÞÇÆãå": Exit Sub
lr = Cells(Rows.Count, "A").End(xlUp).Row
 Dim a As Range
 Set ww = Application.WorksheetFunction
 Set a = Range("A2:z" & lr)
Me.TextBox2.Value = ww.VLookup(Me.ComboBox2.Value, a, 2, False)
Me.TextBox3.Value = ww.VLookup(Me.ComboBox2.Value, a, 3, False)
'Me.TextBox4.Value = ww.VLookup(Me.ComboBox2.Value, a, 4, False)
Me.TextBox5.Value = ww.VLookup(Me.ComboBox2.Value, a, 4, False)
Me.TextBox6.Value = ww.VLookup(Me.ComboBox2.Value, a, 8, False)
Me.TextBox7.Value = ww.VLookup(Me.ComboBox2.Value, a, 9, False)
Me.TextBox8.Value = ww.VLookup(Me.ComboBox2.Value, a, 6, False)
Me.TextBox9.Value = ww.VLookup(Me.ComboBox2.Value, a, 7, False)
End Sub

Private Sub UserForm_Click()

End Sub

 

  • Like 1
قام بنشر (معدل)

سيدى الكريم اسف على ما ازعجك

فهو خطأ غير مقصود  :imsorry:

ثانيا شكرا جزيلا لك على المساعدة  :signthankspin:

سؤال اخر لو تكرمت

عند طباعة الفورم لا يكون على مقاس الورقة a4

مع انى غيرت العرض والطول

فهل هناك كود او العرض والطول الكامل لورقة a4

:fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff::fff:

تم تعديل بواسطه midoboha

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information