excel vba get a range of full rows or columns

'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 find value in range return row excel vba select range of rows using variables vba range entire row vba get column range get row number in range vba vba excel get row number from range vba get columns 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 get rows in a range using vba entire column in excel vba range excel vba range row column reference vba select range with column and row number excel vba reference cell range by row and column number get range of cells vba range entire row vba excel vba range using row and column numbers get row from range vba select row in range vba excel vba code on whole column range cell.row vba excel cell.row vba excel vba array legth values row range of cells vba row column range select entire column in excel vba activate cells entire column vba past column selection vba excel vba macro select a column VBA rows.cells rows.select vba vbscript select row how to select a row in excel vba vba select entire row of active cell select a column in vba how to select a column in vba Excel vba select all columns from row 2 select columns excel vba vba aselect active row new column select full multiple rows formula vba select all rows in excel vba select all row in excel vba row select vba vba select column excel vba select row select full column in excel in vba Columns.Cells vba vba cells all rows excel vba select column how to select a column in excel vba range vba row vba how to call range entire column how to select a whole column in excel vba columns.select vba get row range starts at excel vba vba select column from worksheet excel select column macro select column vba selvba select enrire row active cell and below vba excel row select vba get a range of full rows or columns excel vba get a range of full rows or columns
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