[英]How can I select a specific cell value filtering with the nearest date (in a column) to select a specific row?
[英]Select specific column base on a cell value
從您的帖子中很難理解,根據您所附的屏幕截圖,我猜測可能是以下代碼:
Option Explicit
Sub DynamicSelect()
Dim LastRow As Long, NumofColumns As Long
Dim Rng As Range
LastRow = Cells(Rows.Count, "H").End(xlUp).Row
NumofColumns = Range("L2").Value
' set the range object
Set Rng = Range("H1", Range("H1").Offset(LastRow - 1, NumofColumns))
' if you must Select (not recommended)
Rng.Select
End Sub
你可以這樣
Sub rangeselect()
n = Cells(2, 12)
Dim rng As Range
Dim Str As String
Str = "H1:H" & n
Set rng = Range(Str)
rng.Select
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.