

{"id":99444,"date":"2021-07-28T09:00:46","date_gmt":"2021-07-28T03:30:46","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=99444"},"modified":"2021-07-25T20:20:04","modified_gmt":"2021-07-25T14:50:04","slug":"vba-range-objects","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/","title":{"rendered":"VBA Range Object"},"content":{"rendered":"<h3>What is the VBA Range?<\/h3>\n<p>A cell or multiple cells in excel are represented by VBA range objects. It is one of the important objects in VBA. A range object can represent either a single cell or multiple cells such as a selection of cells, row or column of columns, 3-d range.<\/p>\n<h3>Need of Excel VBA Range:<\/h3>\n<p>The VBA range object helps the VBA to identify what data from the worksheet needs to be involved and executed in the recorded macro. This is where the VBA range object comes into action as it says which all data in the worksheet should take part in it.<\/p>\n<h3>Introduction to Referencing Objects in VBA<\/h3>\n<p><strong>1. Object Qualifier<\/strong><br \/>\nThe user uses object qualifier for referencing the object and this specifies the worksheet referring to.<br \/>\nProperties and methods are used to manipulate the cell values.<\/p>\n<p><strong>2. Property<\/strong><br \/>\nIt stores information about the object<\/p>\n<p><strong>3. Method<\/strong><\/p>\n<p>It is an action of the object which it performs. Range objects can perform actions such as selected, copied, cleared, sorted etc.<\/p>\n<h3>Object Hierarchy Structure<\/h3>\n<p>VBA follows a hierarchy pattern to refer to objects in excel. The user has to follow the following structure to refer to objects.<\/p>\n<p>Note: The \u2018.\u2019 dot connects the objects at each different level such as <strong>Application.Workbook.Worksheets.Range<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Object-Hierarchy-Structure.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99451\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Object-Hierarchy-Structure.jpg\" alt=\"Object Hierarchy Structure\" width=\"389\" height=\"597\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Object-Hierarchy-Structure.jpg 389w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Object-Hierarchy-Structure-320x491.jpg 320w\" sizes=\"auto, (max-width: 389px) 100vw, 389px\" \/><\/a><\/p>\n<h3>How to refer to Excel VBA Range Object using Range property?<\/h3>\n<p>Range property applies in two different types of objects and they are:<\/p>\n<ul>\n<li>Worksheet Objects<\/li>\n<li>Range Objects<\/li>\n<\/ul>\n<h4>Range Property Syntax:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Application.Workbooks(\"DataFlair.xlsm\").Worksheets(\"Articles\").Range(\"A1\")\r\n<\/pre>\n<ul>\n<li>Add the keyword &#8220;Range&#8221;<\/li>\n<li>The keyword should be followed by parentheses.<\/li>\n<li>The relevant Cell Range between the quotations(\u201c \u201d).<\/li>\n<\/ul>\n<h4>Fully qualified reference<\/h4>\n<p>When you refer to a Range object, it refers to fully qualified reference. Here, the user is exactly telling which range they want, what sheet and in what worksheet.<\/p>\n<p><strong>Example:<\/strong> MsgBox Worksheet(&#8220;Articles&#8221;).Range(&#8220;A1&#8221;).Value<br \/>\nUsing Range property, the user can perform many tasks such as,<\/p>\n<ul>\n<li>Referring to a Single cell<\/li>\n<li>Referring to multiple cells such as an entire row or column.<\/li>\n<li>Using Worksheet.Range Property, the user can refer to merged cells also.<\/li>\n<\/ul>\n<p>There are many scenarios and few of them are stated above.<\/p>\n<h4>Refer to a single cell using range property<\/h4>\n<p>Let\u2019s see an example referring to a single cell using the range property.<\/p>\n<p>To refer to a single cell, follow the syntax: Range(\u201ccell\u201d).<\/p>\n<p>Here, the user will use the &#8220;.Select&#8221; command to select the single cell from the worksheet.<\/p>\n<p>To add this in the VBE, follow the steps:<\/p>\n<p>Step 1: Open an excel workbook.<\/p>\n<p>Note: Save the file as an Excel macro-enabled workbook.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/excel-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99452\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/excel-1.png\" alt=\"Excel Macros\" width=\"963\" height=\"493\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/excel-1.png 963w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/excel-1-768x393.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/excel-1-720x369.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/excel-1-520x266.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/excel-1-320x164.png 320w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/a><\/p>\n<p>Step 2: Use macros to add the button.<\/p>\n<p>In order to create a macro,<\/p>\n<ul>\n<li>Select insert from the ribbon under the developer tab.<\/li>\n<li>Click on the command button.<\/li>\n<li>Provide a name to the macro and click on the new button<\/li>\n<\/ul>\n<p>Step 3: Finally, press the ok button.<\/p>\n<p>Step 4: Type the following code in the code window.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nRange(\"A1\") = \"Welcome to DataFlair!\"\r\nEnd Sub\r\n<\/pre>\n<p><strong>Code Explanation:<\/strong><br \/>\nHere, Sub DataFlair_Range() is the sub procedure.<\/p>\n<p>Range(&#8220;A1&#8221;) = &#8220;Welcome to DataFlair!&#8221; denotes that when the code is executed, the A1 cell should contain the value \u201cWelcome to DataFlair!\u201d<\/p>\n<p><strong>Output:<\/strong><br \/>\nThe result will appear in the A1 cell as \u201c Welcome to DataFlair! \u201d<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-code.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99453\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-code.png\" alt=\"VBA range code\" width=\"1471\" height=\"794\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-code.png 1471w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-code-768x415.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-code-720x389.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-code-520x281.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-code-320x173.png 320w\" sizes=\"auto, (max-width: 1471px) 100vw, 1471px\" \/><\/a><\/p>\n<p>The user writes the code in the VBA editor.<\/p>\n<p>Step 5: Click on the save button or press ctrl+s.<\/p>\n<p>Step 6: Close the VBA code editor window.<\/p>\n<p>Your GUI appears as follows:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-gui.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99454\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-gui.png\" alt=\"VBA Range Object GUI\" width=\"953\" height=\"495\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-gui.png 953w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-gui-768x399.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-gui-720x374.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-gui-520x270.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-gui-320x166.png 320w\" sizes=\"auto, (max-width: 953px) 100vw, 953px\" \/><\/a><\/p>\n<p>Once you click on the button, you will get the output:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99455\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op.png\" alt=\"VBA Range Output\" width=\"963\" height=\"498\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op.png 963w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-768x397.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-720x372.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-520x269.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-320x165.png 320w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/a><\/p>\n<h4>The other ranges:<\/h4>\n<table>\n<tbody>\n<tr>\n<td><b>Range For selecting Cell<\/b><\/td>\n<td><b>Range Declaration<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Single Row\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Range(&#8220;1:1&#8221;)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Single Column<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Range(&#8220;A:A&#8221;)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Contiguous cells<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Range(&#8220;A1:D2&#8221;)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Non &#8211; Contiguous cells (Note: There is a comma operator in between the two ranges)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Range(&#8220;A1:C2, D2:D5&#8221;)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Intersection of two ranges (Note: There is no comma operator in between the two ranges)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Range(&#8220;A1:C2 D2:D5&#8221;)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Merge Cells (While merging the cells, use merge command also)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Range(&#8220;A1:D5&#8221;)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Cell Property<\/h3>\n<p>The user uses cell property especially for the purpose of loop programming. Cell property is similar to range and the user can use cell property instead of range. The one main difference is that the cell property has an \u201citem\u201d property which the user uses to reference the cell on the worksheet.<\/p>\n<h4>Cell property syntax:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Cells.item(Row, Col). \r\n<\/pre>\n<p>Here, the row refers to that particular row and the column refers to that particular column in the worksheet.<\/p>\n<p><strong>Example:<\/strong> Cells.item(1,1) , Cells.item(1,&#8221;A&#8221;)<\/p>\n<p><strong>Cell Property Code Sample:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nCells.Item(2, \"A\") = \"Welcome to DataFlair!\"\r\nEnd Sub\r\n<\/pre>\n<p><strong>Code Explanation:<\/strong><br \/>\nCells.Item(2, &#8220;A&#8221;) = &#8220;Welcome to DataFlair!&#8221; denotes that when the code is executed, &#8220;Welcome to DataFlair!&#8221; should appear in the second-row first column i.e., in A2 cell.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-property-code.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99459\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-property-code.png\" alt=\"VBA cell property code\" width=\"1920\" height=\"424\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-property-code.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-property-code-768x170.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-property-code-1536x339.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-property-code-720x159.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-property-code-520x115.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-property-code-320x71.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>When the user runs the code, the following output appears.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-prop-op.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99458\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-prop-op.png\" alt=\"VBA Objects\" width=\"1346\" height=\"988\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-prop-op.png 1346w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-prop-op-768x564.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-prop-op-720x528.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-prop-op-520x382.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/cell-prop-op-320x235.png 320w\" sizes=\"auto, (max-width: 1346px) 100vw, 1346px\" \/><\/a><\/p>\n<h3>VBA Range Offset property<\/h3>\n<p>The user uses the range offset property to select the rows or column away from its original position. The cells are selected according to the range declaration.<\/p>\n<p><strong>Sample Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nRange(\"B1\").Offset(Rowoffset:=1, Columnoffset:=1) = \"Welcome to DataFlair!\"\r\nEnd Sub\r\n<\/pre>\n<p><strong>Code Explanation:<\/strong><br \/>\nRange(&#8220;B1&#8221;).Offset(Rowoffset:=1, Columnoffset:=1) &#8211; This code leads to the C2 cell. The offset property will move the B1 cell to one column and one row away. The given input information value appears in the C2 cell.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-offset-op.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99457\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-offset-op.png\" alt=\"VBA Range Offset Output\" width=\"1516\" height=\"988\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-offset-op.png 1516w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-offset-op-768x501.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-offset-op-720x469.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-offset-op-520x339.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-offset-op-320x209.png 320w\" sizes=\"auto, (max-width: 1516px) 100vw, 1516px\" \/><\/a><\/p>\n<p>Note: The user can also use negative values to move the cells backwards and they can also change the row offset and column offset value as per the requirement.<\/p>\n<h3>VBA &#8211; Excel Objects<\/h3>\n<p>A VBA object in excel can have more than one object. A single workbook can have more worksheets. Workbook, worksheet, range and cells are some of the objects in MS &#8211; Excel. Every object in the sheet has its own properties and they all are executed for different applications.<\/p>\n<p><strong>VBA Object Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub Onj()\r\nDim DataFlair As Object\r\nSet  DataFlair = CreateObject(\"Excel.Sheet\")\r\nDataFlair.Application.Visible = True\r\nDataFlair.Application.Cells(1, 1).Value = \"Welcome to DataFlair!\"\r\nEnd Sub\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99460\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-1.png\" alt=\"VBA Range output\" width=\"963\" height=\"498\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-1.png 963w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-1-768x397.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-1-720x372.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-1-520x269.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/range-op-1-320x165.png 320w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/a><\/p>\n<p>There are other important objects that a user may deal with and they are<\/p>\n<ul>\n<li>Application Objects<\/li>\n<li>Workbook Objects<\/li>\n<li>Worksheet Objects<\/li>\n<li>Range Objects<\/li>\n<\/ul>\n<h4>Application Objects<\/h4>\n<p>In an application object, the application-wide settings and options are available. There are also methods that return top-level objects.<\/p>\n<h5>Application Object Sample<\/h5>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Set dataflair_app = CreateObject(\"Excel.Sheet\") \r\ndataflair_app.Application.Workbooks.Open \"C:\\website.xls\"\r\nApplication.Windows(\"website.xls\").Activate\r\nApplication.ActiveCell.Font.Italics = True\r\n<\/pre>\n<h4>Workbook Objects<\/h4>\n<p>The workbook object is opened in Microsoft Excel and it is one of the workbooks collection.<\/p>\n<h5>Workbook Object Sample<\/h5>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">'To open a workbook\r\nWorkbooks.Open FileName:=\"Website.xlsx\", ReadOnly:=True\r\n<\/pre>\n<h4>Worksheet Objects<\/h4>\n<p>The worksheet object is opened in Microsoft Excel and it is one of the worksheets collection.<\/p>\n<h5>Worksheet Object Sample<\/h5>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">'To protect a WorkSheet\r\nWorksheets(\"Sheet1\").Protect password:=DataFlair, scenarios:=True\r\n<\/pre>\n<h4>Range Objects<\/h4>\n<p>The Range Objects represent a cell, a row, a column, or a selection of cells containing one or more continuous blocks of cells.<\/p>\n<h5>Range Object Sample<\/h5>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">'To insert a value in the range of cells A1:A10\r\nWorksheets(\"Sheet1\").Range(\"A1:A10\").Value = \"123\"\r\n<\/pre>\n<h5>Select<\/h5>\n<p>Select method is one of the important methods in the range object. This method simply selects the range.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nDim DataFlair As Range\r\nSet DataFlair = Range(\"A1: A10\")\r\nDataFlair.Select\r\nEnd Sub\r\n<\/pre>\n<p><strong>Result:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/select-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99461\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/select-1.png\" alt=\"VBA Range Select\" width=\"963\" height=\"499\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/select-1.png 963w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/select-1-768x398.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/select-1-720x373.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/select-1-520x269.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/select-1-320x166.png 320w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/a><\/p>\n<p>Note: To choose a cell on a different worksheet, the user has to activate the sheet first.<br \/>\nFor example, the following code lines select cell A1 on the second worksheet from the left.<br \/>\nWorksheets (2). Activate<br \/>\nWorksheets (2). Range (\u201cA1\u201d). Select<\/p>\n<h5>Rows<\/h5>\n<p>The Rows property in VBA gives access to the specific row in a sheet.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nDim DataFlair as Range\r\nSet DataFlair = Range (\u201cA1: A10\u201d)\r\nDataFlair.Rows(1) .Select \r\nEnd Sub\r\n<\/pre>\n<p><strong>Result:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99462\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row.png\" alt=\"Row in VBA Range\" width=\"1920\" height=\"993\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-768x397.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-1536x794.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-720x372.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-520x269.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-320x166.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h5>Columns<\/h5>\n<p>The columns property in VBA gives access to the specific column in a sheet.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nDim DataFlair as Range\r\nSet DataFlair = Range (\u201cA1: B10\u201d)\r\nDataFlair.Columns(2) .Select \r\nEnd Sub\r\n<\/pre>\n<p><strong>Result:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-choosing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99463\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-choosing.png\" alt=\"column choosing in VBA Range\" width=\"1920\" height=\"986\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-choosing.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-choosing-768x394.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-choosing-1536x789.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-choosing-720x370.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-choosing-520x267.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-choosing-320x164.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h5>Copy\/Paste<\/h5>\n<p>To copy a range, we use the copy method. To paste the copied content somewhere on the sheet, we use the paste method.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nRange (\u201cA1: A10\u201d).Select\r\nSelection.Copy\r\nRange(\u201cC3\u201d).Select\r\nActiveSheet.Paste\r\nEnd Sub\r\n<\/pre>\n<p><strong>Result:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/copy-paste.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99464\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/copy-paste.png\" alt=\"Copy paste in excel VBA Range\" width=\"955\" height=\"496\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/copy-paste.png 955w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/copy-paste-768x399.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/copy-paste-720x374.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/copy-paste-520x270.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/copy-paste-320x166.png 320w\" sizes=\"auto, (max-width: 955px) 100vw, 955px\" \/><\/a><\/p>\n<h5>Clear<\/h5>\n<p>The user can use the ClearContents method to clear the contents of a range in the sheet.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Code: \r\nSub DataFlair_Range()\r\nRange (\u201cA1\u201d) .ClearContents\r\nEnd Sub\r\n<\/pre>\n<p><strong>Result:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/clear.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99465\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/clear.png\" alt=\"Clear in VBA Range\" width=\"1920\" height=\"988\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/clear.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/clear-768x395.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/clear-1536x790.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/clear-720x371.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/clear-520x268.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/clear-320x165.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h5>Count<\/h5>\n<p>The user can count the number of cells, rows and columns of a range using the count property.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nDim DataFlair As Range\r\nSet DataFlair = Range(\u201cA1:A10\u201d)\r\nMsgBox DataFlair.Count\r\nEnd Sub\r\n<\/pre>\n<p><strong>Result:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/count.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99466\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/count.png\" alt=\"Count in VBA Range\" width=\"954\" height=\"497\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/count.png 954w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/count-768x400.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/count-720x375.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/count-520x271.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/count-320x167.png 320w\" sizes=\"auto, (max-width: 954px) 100vw, 954px\" \/><\/a><\/p>\n<h5>Rows Count<\/h5>\n<p>The user can count the number of cells in the row using the count property.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nDim DataFlair As Range\r\nSet DataFlair = Range(\u201cA1:A10\u201d)\r\nMsgBox DataFlair.Rows.Count\r\nEnd Sub\r\n<\/pre>\n<p><strong>Result:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-cpunt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99467\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-cpunt.png\" alt=\"Row Count in VBA Range\" width=\"950\" height=\"497\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-cpunt.png 950w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-cpunt-768x402.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-cpunt-720x377.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-cpunt-520x272.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/row-cpunt-320x167.png 320w\" sizes=\"auto, (max-width: 950px) 100vw, 950px\" \/><\/a><\/p>\n<h5>Columns Count<\/h5>\n<p>The user can count the number of cells in the column using the count property.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Range()\r\nDim DataFlair As Range\r\nSet DataFlair = Range(\u201cA1:B10\u201d)\r\nMsgBox DataFlair.Columns.Count\r\nEnd Sub\r\n<\/pre>\n<p><strong>Result:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-count.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99468\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-count.png\" alt=\"column count in VBA Range\" width=\"955\" height=\"495\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-count.png 955w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-count-768x398.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-count-720x373.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-count-520x270.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/column-count-320x166.png 320w\" sizes=\"auto, (max-width: 955px) 100vw, 955px\" \/><\/a><\/p>\n<h3>Pros and Cons of Excel VBA Object<\/h3>\n<ul>\n<li>The user can make as many objects as required and can link them together to sink it.<\/li>\n<li>VBA objects make use of the workbooks, sheets and range.<\/li>\n<li>The VBA object allows a user to make changes in a specific workbook, worksheet or range.<\/li>\n<\/ul>\n<h3>Things to remember in VBA object<\/h3>\n<ul>\n<li>Both the term worksheet as well as sheet has the same use.<\/li>\n<li>The user can select any worksheet of the same workbook of any number sequence.<\/li>\n<li>The user must save the file in Macro Enabled Excel format. It allows the user to use the code and change the code whenever required.<\/li>\n<\/ul>\n<h3>Excel VBA Named Range<\/h3>\n<p>The named range is a range with specific names and it helps the user to identify which part of the range contains which data.<\/p>\n<p>Let us first know how to name a range in excel<\/p>\n<p>To name a group of cells in excel, the user must select the ranges as follows:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99469\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range.png\" alt=\"name range in VBA\" width=\"1920\" height=\"992\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-768x397.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-1536x794.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-720x372.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-520x269.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-320x165.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>Note: There is a box where it is mentioned as A1. The user can click on that particular box and can provide a name.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99469\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range.png\" alt=\"name range in VBA\" width=\"1920\" height=\"992\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-768x397.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-1536x794.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-720x372.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-520x269.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/name-range-320x165.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>The box is called a name box and the user uses it to give a name to the selected range.<\/p>\n<p>Note: The user can also name the ranges using VBA too but it is a bit more lengthy process than above.<\/p>\n<h4>How to Use Named Range in Excel VBA?<\/h4>\n<p>There are two ways to use the Named Range in Excel VBA:<\/p>\n<p>1. First is that the user can name a range in excel and then use it in VBA.<br \/>\n2. The second method is that the user can make a named range in VBA itself and use its properties.<\/p>\n<h4>Named Range in VBA<\/h4>\n<p>To name a cell range, follow the steps.<\/p>\n<p>1: Select the range which you want to name.<\/p>\n<p>2: There is a name box above the range, the user can make use of it to provide a name to the range.<\/p>\n<p>Note: Here, I have named the range as DataFlair.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/datafl.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99470\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/datafl.png\" alt=\"VBA named Object Range\" width=\"1920\" height=\"996\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/datafl.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/datafl-768x398.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/datafl-1536x797.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/datafl-720x374.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/datafl-520x270.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/datafl-320x166.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>3: Now go to the Developer\u2019s tab from the menu.<\/p>\n<p>4: Click on Visual Basic to get into VBA.<\/p>\n<p>5: Insert a module so that you can write code in it.<\/p>\n<p>6: Write the code as follows.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Sub DataFlair_Rangename()\r\nWorksheets(\"Sheet3\").Activate\r\nRange(\"DataFlair\").Value = 17\r\nEnd Sub\r\n<\/pre>\n<p><strong>Result:<\/strong><br \/>\nOnce you run the above code, you can see that every cell in our named range has the same value<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/17.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99471\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/17.png\" alt=\"\" width=\"1920\" height=\"989\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/17.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/17-768x396.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/17-1536x791.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/17-720x371.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/17-520x268.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/17-320x165.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h3>Cell vs Range<\/h3>\n<p>The user can refer to the cells using two methods. Cell property and range property are the two different methods and now let\u2019s see the differences between those similar properties.<\/p>\n<ul>\n<li>The cell property can select only one cell at a time i.e., Cells(3,3). Here, it chooses the third row&#8217;s third column, which is the C3 cell. If the user wants to select more than one cell together, then the CELLS property cannot do this task.<\/li>\n<li>The range property can select more than one cell at a time, i.e., Range(\u201cA1:A10\u201d). Here, it means that the cells from A1 to A10 are selected.<\/li>\n<\/ul>\n<h3>Summary:<\/h3>\n<p>The VBA Range Object helps to represent a cell or multiple cells in the worksheet. The range objects are specially used for the selection of cells. To manipulate cell values, the user can use property and methods.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is the VBA Range? A cell or multiple cells in excel are represented by VBA range objects. It is one of the important objects in VBA. A range object can represent either a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":99450,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24129],"tags":[24842,24843,24840,24841],"class_list":["post-99444","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ms-excel","tag-excel-vba-range","tag-excel-vba-range-object","tag-vba-range","tag-vba-range-objects"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>VBA Range Object - DataFlair<\/title>\n<meta name=\"description\" content=\"VBA Range Object helps to represent a cell or multiple cells in the worksheet. Learn more about VBA Range Objects and named range.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/vba-range-objects\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VBA Range Object - DataFlair\" \/>\n<meta property=\"og:description\" content=\"VBA Range Object helps to represent a cell or multiple cells in the worksheet. Learn more about VBA Range Objects and named range.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/vba-range-objects\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-28T03:30:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/VBA-Range-Objects-in-MS-Excel.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"VBA Range Object - DataFlair","description":"VBA Range Object helps to represent a cell or multiple cells in the worksheet. Learn more about VBA Range Objects and named range.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/","og_locale":"en_US","og_type":"article","og_title":"VBA Range Object - DataFlair","og_description":"VBA Range Object helps to represent a cell or multiple cells in the worksheet. Learn more about VBA Range Objects and named range.","og_url":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2021-07-28T03:30:46+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/VBA-Range-Objects-in-MS-Excel.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9"},"headline":"VBA Range Object","datePublished":"2021-07-28T03:30:46+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/"},"wordCount":1780,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/VBA-Range-Objects-in-MS-Excel.jpg","keywords":["Excel VBA Range","Excel VBA Range Object","VBA Range","VBA Range Objects"],"articleSection":["MS Excel Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/vba-range-objects\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/","url":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/","name":"VBA Range Object - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/VBA-Range-Objects-in-MS-Excel.jpg","datePublished":"2021-07-28T03:30:46+00:00","description":"VBA Range Object helps to represent a cell or multiple cells in the worksheet. Learn more about VBA Range Objects and named range.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/vba-range-objects\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/VBA-Range-Objects-in-MS-Excel.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/VBA-Range-Objects-in-MS-Excel.jpg","width":1200,"height":628,"caption":"VBA Range Objects in MS Excel"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/vba-range-objects\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"MS Excel Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/ms-excel\/"},{"@type":"ListItem","position":3,"name":"VBA Range Object"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team is a group of passionate educators and industry experts dedicated to providing high-quality online learning resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With years of experience in the field, the team aims to simplify complex topics and help learners advance their careers. At DataFlair, we believe in empowering students and professionals with the knowledge and skills needed to thrive in today\u2019s fast-paced tech industry. Follow us for Free courses, expert insights, tutorials, and practical tips to boost your learning journey.","url":"https:\/\/data-flair.training\/blogs\/author\/datafbdad\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/99444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=99444"}],"version-history":[{"count":2,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/99444\/revisions"}],"predecessor-version":[{"id":99472,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/99444\/revisions\/99472"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/99450"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=99444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=99444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=99444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}