• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Inputbox to select 2 sheets of users choice

Srijithkumar

New Member
I want to select 2 sheets in a workbook of users choice using inputbox.Once vba recognises the two sheet names it should copy a range of values from the first sheet selected to the second one.

For Example
In sheet 1 we have data from (B5:B12) I want to copy this range and paste to sheet 2 (D5:D12). I have attached the file for reference.

Note: The selection of two sheets needs to be of users choice not predefined.


Can someone help me in creating this macro
 

Attachments

Try this little bit. The Application.Input box lets the user select the range/sheet with mouse, making it a bit easier than having to type in the sheet name and range locations.
Code:
Sub CopyData()
Dim rng1 As Range, rng2 As Range

Set rng1 = Application.InputBox("Where is the range to copy?", "Source Range", Type:=8)
Set rng2 = Application.InputBox("Where is the range to paste to?", "Destination Range", Type:=8)
rng1.Copy rng2.Cells(1)
End Sub
 
Back
Top