Tag: 循环

辍学的做或For循环 – 不为我工作

我试图通过在列中添加一个值来根据条件标记行。 在大约35,000行的列中,我有我的数据。 在我通过j列,只有51行,我有我的标准。 b列是空的,如果列c和f满足列i和j中的标准,我想用“KEEP”或“DELETE”填充它。 一旦我点击“KEEP”值,我想要内循环停止并继续外循环。 我真的不知道我在做什么(显然)。 我将不胜感激某人的帮助。 谢谢! Sub test() Dim row As Integer Dim row2 As Integer Dim col As Integer Dim col2 As Integer Dim col3 As Integer Dim col4 As Integer Dim col5 As Integer Dim x As String Dim y As String Dim a As String Dim b As String row […]

VBA Excelmacros – 如何重复每个工作表的macros?

我已经拼凑出了这个完美的macrosVBA。 但是,我需要在同一工作簿中的多个工作表上运行相同的代码。 我已经尝试了很多我在网上看到的东西(SubWorksheetLoop2等),并没有运气。 我们的目标是使用下面的代码,并让它贯穿我的工作簿的所有页面。 我的标签名称是“CLASS II”,“CLASS III”等。请指教! Option Explicit Sub InsertBetweenV3() Dim Area As Range Dim r As Long, lr As Long, sr As Long, er As Long, i enter code here ' turn off screen updating Application.ScreenUpdating = False enter code here ' create an array to fill the 6 inserted rows i = […]

如何在VBA中使用Countifs公式?

我正在写一个有8个工作表的工作簿。 工作表的名称: [ 层次结构,胜利,outlook,PCV,错过,损失,回溯,login ]。 在“ 层次结构 ”工作表中,我想将公式应用到列B中, 直到列B 的最后一个值 (其中包括销售人员的姓名)。 (我想我们将使用循环,我不知道应该使用哪个循环。) =COUNTIFS(wins!$AL:$AL,Hierarchy!$B4,wins!$P:$P,"Complete") PS :我需要上面countif公式和循环(在VBA中)使用该公式直到列中的最后一条logging。

'workbooks.sheets.add'后'不工作

我正在尝试使用macros在特定工作表之后添加工作表。 我们假设这个工作表被命名为102014.我希望这个macros在名字为112014的102014之后创build一个工作表,但是我不能使用select或active工作表,因为它实际上是一个macros的一部分,我来回切换在工作簿之间。 这是我试图做的,没有成功: dim wbname as string dim thismonth as string dim lastmonth as string thismonth = ThisWorkbook.Worksheets("Sheet2").Cells([address of a cell with the name of the sheet).Value lastmonth = ThisWorkbook.Worksheets("Sheet2").Cells([address of a cell with the name of the sheet).Value wbname = ThisWorkbook.Sheets("Sheet2").Cells([address of a cell with the file name here]) Workbooks(wbname).Sheets.Add(After = wbkname.Sheets(lastmonth)).Name = thismonth […]

VBA转到下一个过滤的单元格

我目前使用下面的代码: Sub SendEmail() Dim objOutlook As Object Dim objMail As Object Dim RowsCount As Integer Dim Index As Integer Dim Recipients As String Dim Category As String Dim CellReference As Integer Set objOutlook = CreateObject("Outlook.Application") Set objMail = objOutlook.CreateItem(0) If ActiveSheet.FilterMode = True Then RowsCount = ActiveSheet.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count – 1 ElseIf ActiveSheet.FilterMode = False Then RowsCount […]

使用LINEST 5000次进行梯度计算,无需手动input代码

我正在尝试对一组力 – 距离曲线数据执行梯度计算。 我似乎有100组数据(x,y)的计算代码,尽pipe手动将此数值设置为5000会花费大量时间。 我想知道是否有一个函数可以执行以计算5000组x,y数据。 它是一个循环function? 对不起,但我是一个生物物理学家和新的编码。 下面是我的代码的一些例子: Sub S_Grad_Extraction() ' ' S_Grad_Extraction Macro ' ' Sheets.Add After:=ActiveSheet ActiveCell.FormulaR1C1 = _ "=LINEST(Sheet1!R[10]C:R[14]C,Sheet1!R[10]C[1]:R[14]C[1])" Range("A2").Select ActiveCell.FormulaR1C1 = _ "=LINEST(Sheet1!R[9]C[2]:R[13]C[2],Sheet1!R[9]C[3]:R[13]C[3])" Range("A3").Select ActiveCell.FormulaR1C1 = _ "=LINEST(Sheet1!R[8]C[4]:R[12]C[4],Sheet1!R[8]C[5]:R[12]C[5])" Range("A4").Select ActiveCell.FormulaR1C1 = _ "=LINEST(Sheet1!R[7]C[6]:R[11]C[6],Sheet1!R[7]C[7]:R[11]C[7])" Range("A5").Select 编辑:添加到代码块

用excel操作variables

语言:Excel 您好,感谢您阅读我的文章。 我正在尝试创build一个公式,以便…根据variables乘以单元格(或在这种情况下的字母)。 variables是可以被(1000 + 250x)整除的,根据答案乘以相应的字母百分比。 视觉performance: ABC 1% 2% 3% 250 500 1000 1 1,000 2 1,250 3 1,500 4 1,750 5 2,000 例如,因为#1可以被1000整除,所以我会把它乘以3%二次,因为#2可以被250整除,1000,我会把250乘以1%和1000乘以3%,然后add他们在一起。 我目前的尝试: =IF(MOD(A2,F14)<=1,A2*F15,"") A2 =起始金额F14 = A2除以的金额 F15 =百分比 这种作品,但它不允许我find最好的解决scheme 。 将非常感谢您在我的困境中的帮助。

按特定间隔循环复制粘贴

我是一个初学者,试图运行一个这样做的VBA: 从起点复制公式(单元格B6) 将该公式每隔18行粘贴到同一列上 重复该过程,直到单元格显示“报告结束” 我有下面的代码,我不能让它正常运行(只从现有的报告inheritance公式): '(a) to set the formula at starting point: Windows("RAVEN MNL adj.xlsm").Activate Range("B6").Select ActiveCell.FormulaR1C1 = "=TRIM(RIGHT(RC[-1],7))" '(b) to copy paste in loop Dim i As Long Dim ii As Long Dim strLastCell As Long Dim rng As Range Set rng = Range("B:B").Cells strLastCell = rng.Find(what:="End of Report", After:=rng.Cells(1), Lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, […]

范围对象通过“工作表1”而不是“工作表2”

我有一个迭代遍历for循环中的一系列项目的问题: 程序如何工作 – 我从工作表1开始(“跟踪电子表格”),并根据工作表1中的更改​​(在单元格中select“是”),它会将您转移到工作表2(“延期送达”),然后遍历从工作表2中的单元格(例如A1:A20)。for循环将继续前进,直到它到达空单元格为止,然后停止然后继续写入该单元格。 现在如何工作 – 我从工作表1开始,根据工作表1中的更改​​(在单元格中select“是”),它会将您转移到工作表2,然后从工作表2中遍历一系列单元格(例如A1:A20)。但是,不是遍历工作表2的A1:A20,而是遍历工作表1的A1:A20。 在工作表1的A1:A20范围内find一个空单元格后,它将填充工作表2中的相应单元格(如果A5在工作表1上为空,则会在工作表2上填写A5)。 我希望得到帮助的范围迭代通过活动工作表(工作表2),而不是迭代通过工作表1。 我的代码到目前为止: Private Sub Worksheet_Change(ByVal Target As Excel.Range) ' Deferred Submittal, Column C = 3 Dim cellTextDS As String Dim deferredArray As Range, deferredCell As Range, deferredRowEmpty As Long deferredRowEmpty = 1 ' Deferred Submittal, Column C If Target.Column = 3 Then Row = Target.Row cellTextDS = […]

添加新的Excel工作表时出现错误400

理想情况下,这个macros将循环遍历每个公司名称的列表,并为每个公司的信息创build一个新的选项卡,但是我为在这个macros的末尾创build一个新的选项卡而苦苦挣扎,因为它给了我错误400。 Sub getStockPrices() Dim DataSheet As Worksheet Dim EndDate As Date Dim StartDate As Date Dim Symbol As String Dim Interval As String Dim qurl As String Dim nQuery As Name Dim LastRow As Integer Application.ScreenUpdating = False Application.DisplayAlerts = False Application.Calculation = xlCalculationManual Sheets("data").Cells.Clear Set DataSheet = ActiveSheet StartDate = DataSheet.Range("startDate").Value EndDate = DataSheet.Range("endDate").Value […]