Home > Software engineering >  Reads the excel spreadsheet Combo1 how to transfer to the Combo2
Reads the excel spreadsheet Combo1 how to transfer to the Combo2

Time:09-19

Private Sub Combo1_Click ()
'Dim dongexcel As Object
'Dim dongbook As Object
'Dim dongsheet As Object
Dim dongexcel As New Excel. Application
Dim dongbook As Excel. The Workbook
Dim dongsheet As Excel. The Worksheet
Dim J As Integer

If Combo1. Text="dongyang change" Or Combo1. Text="tong crane become" Or Combo1. Text="gold stone change" Or Combo1. Text="deep ze change" Then

'Set dongexcel=CreateObject (" Excel. Application ")
Set dongbook=dongexcel. Application. Workbooks. Open (" C: \ Users/Administrator/Desktop/QC \ dongyang ops class operation task. XLSX ", ReadOnly:=False)
Dongbook. Close True
'Set dongbook=GetObject (" C: \ Users/Administrator/Desktop/QC \ dongyang ops class operation task. XLSX ")
'dongexcel. Visible=True
'Set dongbook=dongexcel. Workbooks. Open (" C: \ Users/Administrator/Desktop/QC \ dongyang ops class operation task. XLSX ")
'dongexcel. Visible=False
The Set dongsheet=dongbook. Worksheets (Combo1. Text)

Combo2. Clear
'read interval name
I=dongsheet. UsedRange. Rows. Count
Combo2. AddItem dongsheet. Cells (1, 1). The Value
For J=2 To I
If dongsheet. Cells (J, 1) & lt;> Dongsheet. Cells (J - 1, 1), Then the
Combo2. AddItem dongsheet. Cells (J, 1). The Value

End the If
Next
The Else
Combo2. Clear
MsgBox "please select a substation!"
End the If

End Sub


Private Sub Combo2_Change ()
Dim V2 As String
Dim II As Integer
V2=Combo2. Text
For II=0 To Combo2. ListCount - 1
If UCase (Combo2. List (II)) Like V2 & amp; "*" Then
Combo2. Text=Combo2. List (II) :
Combo2. SelStart=Len (V2) :
Combo2. SelLength=Len (Combo2. Text) - Len (V2) :
End the If
Next
End Sub



Private Sub Combo2_Click ()
Combo3. Clear
J=1
Dim CDCD As String
CDCD=dongsheet. Cells (J, 1). The Value
For J=1 To I
1, If dongsheet. Cells (J) Value=https://bbs.csdn.net/topics/Combo2.Text Then

Combo3. AddItem dongsheet. Cells (J, 2). The Value
End the If
Next

'Combo3. Clear
'MsgBox "please select operation mission!"
'End If
End Sub
Have read through the combo1 dongsheet this way in combo2 direct reference? And the execution of the Set dongbook=dongexcel. Application. Workbooks. Open (" C: \ Users/Administrator/Desktop/QC \ dongyang ops class operation task. XLSX ", ReadOnly:=False) why would prompt the object of the Open workbook failure, consult, thank you!

CodePudding user response:

Close the UAC, firewall, anti-virus software,...
As an administrator to run

CodePudding user response:

I also am dongyang people oh, hengdian, QQ2776478814

CodePudding user response:

reference 1st floor zhao4zhong1 response:
close the UAC, firewalls, antivirus software,...
As an administrator to run

Not ah, I've tried, there are other ways? Thank you very much!

CodePudding user response:

Use clipboard?

CodePudding user response:

Use clipboard, began keeping records in Excel macro, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,

CodePudding user response:

reference 5 floor zhao4zhong1 reply:
using the clipboard, began keeping records in Excel macro, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,

Thank you miss zhao's answer to check the corresponding VBA code is for the sake of what?

CodePudding user response:

refer to 6th floor u011222864 response:
Quote: refer to the fifth floor zhao4zhong1 reply:

Use clipboard, began keeping records in Excel macro, manual, complete the required function end record macros, press Alt + F11 key, view the corresponding VBA macro code just record,

Thank you miss zhao's answer to check the corresponding VBA code is for the sake of what?

Slavish written in VB program,
  • Related