Тёмный

How to Use a Last Row Function in ANY Excel Workbook With & Without VBA! 

Meraz Mamun - Analytics
Подписаться 318
Просмотров 119
50% 1

Опубликовано:

 

25 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 1   
@merazmamun-analytics
@merazmamun-analytics 6 дней назад
This is the VBA code to use the LAMBDA function in any Excel Workbook: Sub custom_function_with_lambda() 'This LAMBDA function is used to find the last row number for any single column ActiveWorkbook.Names.Add Name:="_last_row", RefersToR1C1:= _ "=LAMBDA(col_range,LOOKUP(2, 1/(col_range""""),ROW(col_range)))" ActiveWorkbook.Names("_last_row").Comment = "This custom function is used to find the last row number for any single column. Parameter: col_range" End Sub These are the VBA code for the UDFs last_row_v1 and last_row_v2: 'One version of the last row function Function last_row_v1(col_range As Range) As Long 'Turn on error handling On Error Resume Next 'Find the last row based on the entire column. last_row_v1 = col_range.Worksheet.Cells(col_range.Worksheet.Rows.Count, col_range.Column).End(xlUp).Row 'If error occurs... If (Err.Number 0) Then 'Last row will be equal to 0 last_row_v1 = 0 'Clear the error Err.Clear End If 'Turn off error handling On Error GoTo 0 End Function 'Another version of the last row function Function last_row_v2(col_range As Range) As Long 'Range variable used to loop through each cell in the selected range Dim cell As Range 'Long variable used to store the current last row number in each looped cell Dim last_row As Long 'Turn on error handling On Error Resume Next 'Loop through each cell in selected range For Each cell In col_range 'If current cell is not blank, then store the current row number into last_row variable If (cell.Value "") Then last_row = cell.Row End If Next cell 'Store the value in last_row to last_row_v2 for output last_row_v2 = last_row 'If error occurs... If (Err.Number 0) Then 'Last row will be equal to 0 last_row_v2 = 0 'Clear the error Err.Clear End If 'Turn off error handling On Error GoTo 0 End Function
Далее
Next.js 15 Breakdown (Everything You Need To Know)
18:10