我想将在宏中确定的变量的值(在下面的代码中为LastRow)放入电子表格中。最终,我希望将其作为“名称管理器”中定义的数量以用于其他操作,但是如果我可以将其粘贴到电子表格单元格中,那么我知道如何添加“名称管理器”。
尝试搜索和粘贴各种操作,没有乐趣。
欣赏您的建议。
Sub A_copy_pressure_arrays()
Dim oSWksht As Excel.Worksheet
Dim oDWksht1 As Excel.Worksheet
Dim c As Range, v
Dim k As Range, j
Dim LastRow
Set oSWksht = ActiveWorkbook.Worksheets("data")
Set oDWksht1 = ActiveWorkbook.Worksheets("psia")
oSWksht.Columns(1).Copy Destination:=oDWksht1.Columns(1)
oSWksht.Columns(3).Copy Destination:=oDWksht1.Columns(2)
j = 3
For Each c In Application.Intersect(oSWksht.Rows(2), oSWksht.UsedRange)
v = Trim(c.Value)
If v Like "P.#" Or v Like "P.##" Then
c.EntireColumn.Copy Destination:=oDWksht1.Cells(1, j)
j = j + 1
End If
Next c
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Debug.Print "Last row " & LastRow
End Sub