INTRODUCTION: Range Or Cells Is Used To Define The Start And End Point For A Particular Selection Of Cells. Examples “A1:A5” or “A1” Etc…
- Open Excel File
- Click Alt + F11
- One Dialog Screen Will Get Open
- Click Insert And Add Module
- Create Sub Procedure
- Make Sure The Procedure Name Start With String And Without Space.
- Write The Code In Between Sub And Sub End
- Click Run Button
- By Clicking The Range Data Will Get Selected.
- Declare Variable – Dim RNG as Range / To Copy And Paste Data Use Dim Copyy= Range(“A1:A6”) / Dim Pastee As Range
- Note We Cannot Use Excel By Default Keyword Like Copy – Paste – Cut As Variable.
- Range Is Object So We Will Need To Use Set Keyword To Apply Particular Range.
- For Select The Range Use Set RNG = Range(“A1:A5”).Select
- To Copy The Data Use Set Copyy= Range(“A1:A5”)
- To Paste The Data Use Set Pastee= Range(“B1:B5”)
- To Automate The Process Using Button Please Insert A Button Right Click And Assign Related Procedure / Macro To A Button.
- Any Sub Procedure / Macro Can Be Assign To A Button Like This Example To Fire The Event On Clicking The Button.
- That’s It 🙂
- Please Check The Images And Video For More Info.