標題:
[發問]
USERFORM裡的COMBOBOX 與 TEXTBOX 的應用
[打印本頁]
作者:
eeda60
時間:
2013-7-26 11:05
標題:
USERFORM裡的COMBOBOX 與 TEXTBOX 的應用
USERFORM裡的COMBOBOX 與 TEXTBOX 的應用
Sub 123()
'
Dim i As Long, Ur$, Rng As Range, R As Long
For i = 123000 To 123456
Ur = "102JD" & Format(i, "000000")
R = ActiveSheet.UsedRange.Rows.Count
Set Rng = ActiveSheet.Range("A" & IIf(R = 1, 0, R) + 1)
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://XXX.XXXX.XXX/XXXXXX/XXXX_XXX_XXXXXXX.XXX?XXXXXXXXXX=" & Ur _
, Destination:=Rng)
.Name = "XXXX_XXX_XXXXXXX.XXX?XXXXXXXXXX=" & Ur
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End Sub
複製代碼
試問 1.如何使 For i = 123000 To 123456 中的數字 123000與123456由 USERFORM1 裡的 TEXTBOX2、 TEXTBOX3 代替
2.如何使 Ur = "102JD" & Format(i, "000000") 中的 102JD 由USERFORM1 裡的TEXTBOX1取代102 、 COMBOBOX1取代JD
作者:
GBKEE
時間:
2013-7-26 12:43
回復
1#
eeda60
多看看一些vba範例會進步的
' Sub 123() '在USERFORM的模組裡
For i = Val(TEXTBOX2) To Val(TEXTBOX3)
Ur = TEXTBOX1 & COMBOBOX1 & Format(i, "000000")
' Sub 123() '不在USERFORM的模組裡
With USERFORMaaa
For i = Val(.TEXTBOX2) To Val(.TEXTBOX3)
Ur = .TEXTBOX1 & .COMBOBOX1 & Format(i, "000000")
'
'
Next
End With
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)