使用VBA Excel将区域中的单元格值递增1 您所在的位置:网站首页 excel添加一个按钮 使用VBA Excel将区域中的单元格值递增1

使用VBA Excel将区域中的单元格值递增1

2023-05-29 20:12| 来源: 网络整理| 查看: 265

我目前正在尝试实现一个插入新行值和一个自动复选框插入器。

我目前有以下代码分散在不同的按钮,因此不同的Subs。我将需要增加1个单元格的关键信息加粗。这将在单击"InsertNewBill“按钮后发生:

Private Sub InsertNewBill_Click() 'I AM USING i TO STORE THE CELL INCREMENT, IT CURRENTLY DOES NOTHING** Dim i As Integer '**range("A30:AC30").Select** '**range("AC30").Activate** Selection.Copy Selection.Insert Shift:=xlDown End Sub Private Sub DeleteTickBoxes_Click() 'Variables Dim c As CheckBox Dim CellRange As Range Dim cel As Range Set CellRange = ActiveSheet.Range("E7:**F30**") 'Delete Checkboxes within the specified range above on the ActiveSheet Only For Each c In ActiveSheet.CheckBoxes If Not Intersect(c.TopLeftCell, CellRange) Is Nothing Then c.Delete End If Next 'Insert New Checkboxes and Assign to a specified link cell using the offset For Each cel In CellRange 'you can adjust left, top, height, width to your needs Set c = ActiveSheet.CheckBoxes.Add(cel.Left, cel.Top, 30, 6) With c 'Clears the textbox so it has no text .Caption = "" 'Offset works by offsetting (Row offset, Column Offset) and accepts 'positive for down/right and negative for left/up, 'keep in not that the linked cells will automatically populate with true/false .LinkedCell = cel.Offset(0, -4).Address End With Next Call CentreCheckbox_Click End Sub

我需要所有加粗的值加一。即从F30到F31和A30:AC30到A31:AC31。该值还需要从InsertNewBill_Click子节点传递到DeleteTickBoxes_Click子节点。

我假设我将需要删除Private sub,并且可能有一个公共整数变量?我只是不确定如何实现在每次点击按钮后仅将数字增加1。

非常感谢您的帮助



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有