excel vba get a range of full rows

To get a contiguous range of entire rows, use this VBA function:

Function WSRows(ws As Worksheet, Row1&, Rows&)
    Set WSRows = ws.Rows(Row1).Resize(Rows)
End Function
  
'-----------------------------------------------------------------
  
MsgBox WSRows(Sheet1, 11, 9).Address		'<--displays: $11:$20
  
'To get the values in the range into a variant array:  
v =  WSRows(Sheet1, 11, 9)
   
'-----------------------------------------------------------------
 
  
'Sister function to a get range of contiguous full columns:  
  
Function WSCols(ws As Worksheet, Col1&, Cols&)
    Set WSCols = ws.Columns(Col1).Resize(, Cols)
End Function

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
excel vba get range of cells with values loop vba find in range row excel vba find value in range return row excel vba range get column How to fill a value into a range of selected cells vba excel vba select range of rows excel vba select range of rows using variables vba range entire row get row number in range vba excel vba get row and column from range excel vba range get type of data in cell vba excel get used range excel vba get selected range vba all rows of range vba excel get row number from range excel vba get row of range select range using row and column excel vba select a range of cells in excel with values vba excel vba return row from range excel vba get value from range one cell excel vba get value from range vba get row of selected range excel vba get range position get rows in a range using vba get range of table in excel using vba get value from range row using column heading using vba count range row vba exxcel vba select range with column and row number get range of cells vba vba select a range in a row excel vba get range of cells range entire row vba read entire range excel vba excel vba get range from find vba get selected range row get row from range vba vba get range of sheet cell get range vba excel get selected range vba excel vba get cell value from named range excel vba table range multiple columns RANGE ROWS excel Worksheet.Rows as Excel.Range vba number rows 5 methods excel single row range vba range with rows excel vba get a range of full rows
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source