English 中文(简体)
我需要用不同幅度取代方括号内的范围
原标题:I need to replace a square bracketed range with a variable range
  • 时间:2024-03-07 01:11:01
  •  标签:
  • excel
  • vba

我有一个宏观方案,将公式化成两维范围,并正确地增加相对地址。 然而,范围是“硬编码”,我需要能够以方案方式确定范围深度。 我的法典使用方括号来确定范围,似乎你可以在方括号内使用一个变量(或者至少我可以说明如何这样做)。

我需要该守则使用一个变量来界定范围的最底层右侧角。 我的想法非常有益。

我想取代<代码>[T3:DX321]。 公式...


    Dim Lastrow As Long
    Lastrow = BillSch.Range("S" & Rows.Count).End(xlUp).row   Last row of BillSch
        
         This code works but I need the lastrow of DX to be a variable
        [T3:DX321].Formula = "=IFERROR(XLOOKUP(1,(BS_ORDERNO=$S3)*(BS_WEEKNO=T$1),BS_CHARGEDPRICE),"""")"

        These two attempts were failures
         [T3:DX" & lastrow].Formula = "=IFERROR...."   ERROR--  "Runtime error 434 Object required

         Dim Rng As Range
         Rng = BillSch.Range("T3:DX" & Lastrow)   ERROR--  "Object variable or With block variable not set"
         Rng.Formula = "=IFERROR(XLOOKUP(1,(BS_ORDERNO=$S3)*(BS_WEEKNO=T$1),BS_CHARGEDPRICE),"""")"
End Sub
问题回答
  • [..] in your code is equalent to Evaluate(".."). It s better to use Range(..) object.
    Range("T3:DX" & Lastrow).Formula = "=IFERROR(XLOOKUP(1,(BS_ORDERNO=$S3)*(BS_WEEKNO=T$1),BS_CHARGEDPRICE),"""")"




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签