Find excel range Dynamically using VBA code

I have Excel Output, whose rows and columns are dynamic on weekly execution.
How to select the range ??

i want an VBA code


the value is started from B2 in every time

these is the code but ranges varies dynamically

Hi @Melbin_Antu1

Can you try the below

NewFile.txt (551 Bytes)

or

If the value is started from B2 every time then try below

image

Cheers!!

tesst.xlsx (112.9 KB)
this is my sheet it cant perform the code

Sub SelectDynamicRange()
Dim lastRow As Long
Dim lastColumn As Long
Dim ws As Worksheet

' Set the worksheet reference
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your actual sheet name

' Find the last row and last column with data
lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
lastColumn = ws.Cells(2, ws.Columns.Count).End(xlToLeft).Column

' Select the range starting from B2 to the last row and last column
ws.Range("B2", ws.Cells(lastRow, lastColumn)).Select

End Sub

@Melbin_Antu1

What is your required output

fill the blank cells with zero

@Melbin_Antu1

Can you try the below

New Text Document.txt (715 Bytes)

tesst.xlsx (244.5 KB)

Cheers!!

Oh Thanks, Can You Share that Workflow

@Melbin_Antu1

You can extract the below file and run the bot

BlankProcess18.zip (240.6 KB)

Cheers!!

Thanks Bro its Working :+1:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.