نوشته اصلی توسط
alisabet
با سلام حضور اساتید گرامی و کاربران محترم انجمن
خواهش میکنم راهنمائی بفرمائید شکل داینامیک این کد چگونه است
کد PHP:
Sheets("Sheet1").scrollarea="A1:J100"
منظورم اینست که اگر مثلاً شماره ستون متغیر بود یا ردیف متغیر بود شکل کد چگونه میشود
با سلام
این کد را امتحان کنید
کد PHP:
Me.ScrollArea = Range(Cells(1, 1), Cells(LastRow, LastColumn)).Address
کد PHP:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LastColumn As Integer
Dim LastRow As Long
If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Rows.
LastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
If LastRow <> 65536 Then LastRow = LastRow + 1
'Search for any entry, by searching backwards by Columns.
LastColumn = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
If LastColumn <> 256 Then LastColumn = LastColumn + 1
Me.ScrollArea = Range(Cells(1, 1), Cells(LastRow, LastColumn)).Address
Else
Me.ScrollArea = ""
End If
End Sub
علاقه مندی ها (Bookmarks)