VBA Excell。 根据活动工作表更改偏移量

我试图找出如何我可以根据活动工作表编号作出抵消。

例:

现在在单元格“B1”的表格2中,我有一个17000的数字在B8的同一个表格上:B我有一串数字,下降了一些值,我想加起来到17000的基数。一旦我做了一个新的工作表,我想要“A1”加上其他两个数字的价值。

我有一个代码“填充”即时通讯使用的活动表。 但是我怎么能这样做,在每张新的表格中,它将在Collum B8:B中下降1个位置

所以表2具有将被使用的值。

  • 新工作表nmbr 5被创build将需要工作表2“B1”+“B8”
  • 新工作表nmbr 6得到创build将需要工作表2“B1”+“B9”
  • 新工作表nmbr 7被创build将需要工作表2“B1”+“B10”

等等等等。

Sub KnopKlik() Dim WB As Workbook Dim WS1 As Worksheet Dim WS2 As Worksheet Dim WS3 As Worksheet Dim Active As Worksheet Dim Titel1 Dim Titel2 Set WB = ActiveWorkbook Set WS1 = WB.Sheets(1) Set WS2 = WB.Sheets(2) Set WS3 = WB.Sheets(3) Set Active = WB.ActiveSheet Set MC = Active.Range("B9") Titel1 = WS2.Range("B1") 'Base number of 17000 Titel2 = WS2.Range("B8") 'Has to be added up to 17000 depanding on sheet number collum1 = Sheets(3).Cells(1, 3).Value Application.ScreenUpdating = False '============================================================ Sheets(1).Visible = True ' Activate Sheets Sheets(2).Visible = True Sheets(3).Visible = True Active.Select ActiveSheet.Range("A1").Value = "Unit " & (Titel1 + Titel2) 'This is the line that is suppose to write the question i asked. '============================================================================= ' Between these lines is a bunch of code i left out cause its irrelivant to the question. '============================================================================= Application.ScreenUpdating = True Active.Select Sheets(1).Visible = xlVeryHidden Sheets(3).Visible = xlVeryHidden Sheets(4).Visible = xlVeryHidden MsgBox ("Done") End Sub 

我希望这个问题不难理解。 我得到了我想要的东西,但我觉得很难用英语解释:P

好的,试试

  Titel2 = WS2.cells(4 + activesheet.index,2)