
Always save the excel file as Macro Enable excel to prevent losing the code.Random selection of cell is not allowed with these shown examples.We can choose any type of range but, make sure the range of cells is in sequence.Means, the cell with the data will stop and prevent us from taking to the far end of the sheet.
#EXCEL VBA ON STARTUP SELECT SHEEN CODE#
Using xlDown/Up and xlToLeft/Right command in code will take us to cells which is a far end or to the cell which has data.Selecting the range cells and putting the data into that can be done simultaneously with one line of code.We can select and fill the cells which are only possible in excel by Find and Replace option.We can choose any type of range which we cannot do manually.This is as easy as selecting the range of cells manually in Excel.Below is the code for selecting the far down cell of a sheet from reference cell B1. In a similar way, we can move the cursor and select the cell of the far down or up location of any sheet by xlDown or xlUP. We will see, our cursor from anywhere from the first row or cell B1 will move to the far end to the sheet. Step 4: Now run the code by pressing F5 key. Step 3: Now to move to the End table or sheet towards right we will use xlToRight and for left it would be changed to xlToLeft as shown below. Step 2: Choose the reference range cell from where we want to move the cursor. Step 1: Write the subcategory of VBA Selection Range again. Follow the below steps to use VBA Selection Range. In Excel, this process is done manually by Ctrl + any Arrow key. This process of selecting the end cell of the table or blank worksheet is quite useful in changing the location from where we can select the range.
#EXCEL VBA ON STARTUP SELECT SHEEN HOW TO#
In this example, we will see how to move the cursor from a current cell to the far most end cell. We will see, the selected cells from A1 to C3 got the value as My Range and those cells are still selected. Step 6: Now again run the code by clicking on Play Button. Here our value is the same as we used before as My Range. Step 5: For this use Selection function along with Value and choose the value which we want to see. Or we can select the new range of cells manually also to see the changes by this code. We will see, the cells from A1 to C3 of the worksheet which is Name as Sheet2 are now selected.Īs we have already selected the cells which we wanted, so now we can again write the one line code by which we will insert any text to selected cells. Step 4: Now run the code by clicking on the Play Button. Here we are considering the same range from cell A1 to C3. Step 3: Now again as per example-1, we will select the range of the cells which want to select. Use Worksheet function to activate the sheet which wants by putting the name or sequence of the worksheet.

We don’t need to make that sheet as current. Step 2: By this process, we can select the range of any specific sheet which we want. Step 1: Write the subcategory of VBA Selection Range as shown below. There is another way to implement VBA Selection Range. We will see the required text which we were in code value is got printed to the selected range. Now again run the code by clicking on the Play Button. Now assign any value or text which we want to see in the selected range cells. For this we will use Value function instead of Select. In a similar way, we can put any value to selected range cells. We will see the changes in the current sheet as cells from A1 to C3 are selected as shown below. Step 5: Now compile the code and run it by clicking on the Play button located below the menu bar. We can select the cells, select the values it has or copy the selected range as well.

Further, we can apply any function to it.
