excel-2007

VBA Refer to TextBox or Label using a loop

柔情痞子 提交于 2021-01-03 06:16:24
问题 I am trying to replace the following: txt1.Text = "" txt2.Text = "" txt3.Text = "" txt4.text = "" ...continues for quite awhile With: Dim cCont As Control For Each cCont In Me.Controls If TypeName(cCont) = "TextBox" Then 'reset textbox value ??? End If Next cCont How do I refer to the textbox using the generic 'Control'? 回答1: You already have your control in cCont. Dim cCont As Control For Each cCont In Me.Controls If TypeOf cCont Is MSForms.TextBox Then cCont.Text = "hi" MsgBox cCont.Name

Strange ActiveX Listbox behavior in Excel

 ̄綄美尐妖づ 提交于 2020-07-22 10:25:27
问题 In Excel 2007 SP3, I have a workbook with a multi-column, multi-select ActiveX listbox. On most computers it works fine. But on one user's computer, when I read from that listbox and write data from it to another sheet, it's font gets smaller. And smaller again each time the command button that does task is clicked. All of our computers are on Excel 2007 SP3 and Windows 7. Only one of them has this problem; it works fine on the others. Stepping through the code on the affected computer, I

Type mismatch when setting a formula into a cell with VBA

不羁岁月 提交于 2020-07-09 14:49:44
问题 Worksheets("sheet2").Range("C2").Formula = "=AVERAGEIFS(Sheet1!E:E,Sheet1!A:A," >= "&A2,Sheet1!A:A," < "&B2)" I have run the above code in Excel 2007 and I'm getting a run time error 13 type mismatch The above code is used to do average operation from sheet 1 and enter in sheet 2. I request some help in correcting the error. 回答1: The issue is you need to escape the quotes with another quote. That means all quotes " in the formula become "" . If the formula in that cell should be =AVERAGEIFS

Type mismatch when setting a formula into a cell with VBA

℡╲_俬逩灬. 提交于 2020-07-09 14:48:13
问题 Worksheets("sheet2").Range("C2").Formula = "=AVERAGEIFS(Sheet1!E:E,Sheet1!A:A," >= "&A2,Sheet1!A:A," < "&B2)" I have run the above code in Excel 2007 and I'm getting a run time error 13 type mismatch The above code is used to do average operation from sheet 1 and enter in sheet 2. I request some help in correcting the error. 回答1: The issue is you need to escape the quotes with another quote. That means all quotes " in the formula become "" . If the formula in that cell should be =AVERAGEIFS

Compile error 'named argument not found'

主宰稳场 提交于 2020-06-18 12:09:47
问题 Excel 2007 Sub Filtered_data_on_othersheet() Dim i As Integer Dim xx As String For i = 1 To 3 On Error Resume Next xx = Sheets("main").Range("K" & i).Value Range("A1").CurrentRegion.AutoFilter field:=1, Criterial:=xx Range("A1").CurrentRegion.Cells.SpecialCells(xlCellTypeConstants).Copy Destination:=Sheets(xx).Range("A1") Next Err.Clear Range("A1").CurrentRegion.AutoFilter End Sub 回答1: Simple mistake. It should be Criteria1 not Criterial Use the number 1 instead of the letter l . 来源: https:/

Compile error 'named argument not found'

倾然丶 夕夏残阳落幕 提交于 2020-06-18 12:05:35
问题 Excel 2007 Sub Filtered_data_on_othersheet() Dim i As Integer Dim xx As String For i = 1 To 3 On Error Resume Next xx = Sheets("main").Range("K" & i).Value Range("A1").CurrentRegion.AutoFilter field:=1, Criterial:=xx Range("A1").CurrentRegion.Cells.SpecialCells(xlCellTypeConstants).Copy Destination:=Sheets(xx).Range("A1") Next Err.Clear Range("A1").CurrentRegion.AutoFilter End Sub 回答1: Simple mistake. It should be Criteria1 not Criterial Use the number 1 instead of the letter l . 来源: https:/