Using Input Box Select Named Range & paste special data

KayWill

New Member
Joined
Jan 22, 2015
Messages
36
Back again! I'm hoping that someone can help. I have a worksheet where I am copying the values that the user double clicks on and I want an input box (if that's the correct thing to use) to allow the USER to advise the named range to paste special the value to. Currently there are three named ranges: ADA (C10:C20), REMODEL (E10:E20) & TTLBID (H10:H20). I would like for the selection the user double clicks on to paste to the same row in the named range selected. Is this possible or am I wishing on a star here? I have a code that actually does the first part which is allowing user to double click & copy values but when it comes to pasting, it wants the user to select where to paste and that's not what I'm looking for. You can tell by my dialogue I'm no where near an expert, more of a novice using excel more and more and just looking for assistance. This is what I have thus far:

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
Set ws = ThisWorkbook.Worksheets("SRW-Master")
If Not Intersect(Target, Range("C51:D62")) Is Nothing Then
    Cancel = True
    ADA = Range("TTLADA_SITEWK")
    REMODEL = Range("REMODEL")
    TTLBID = Range("TTLBID")

    Set Ret = Application.InputBox(Prompt:="Please type ADA, REMODEL or TTLBID to paste value in totals", Type:=1)
    On Error GoTo 0
    If Not Ret Is Nothing Then
    Target.Copy
        Ret.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
    End If
    
  End If
End Sub

Again, any assistance will be greatly appreciated.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
SOLVED!: Using Input Box Select Named Range & paste special data

Thanks to STEPHENR! this was solved, for anyone interested, the code is below:

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) 
     
    Set ws = ThisWorkbook.Worksheets("SRW-Master") 
    If Not Intersect(Target, Range("C51:D62")) Is Nothing Then 
        Cancel = True 
         'Set ADA = Range("ADA_SITE")
         'Set REMODEL = Range("REMODEL_SITE")
         'Set TTLBID = Range("TTLBID_SITE")
        Ret = Application.InputBox(Prompt:="Please type ADA, REMODEL or TTLBID to paste value in totals", Type:=2) 
        If Ret = "ADA" Or Ret = "REMODEL" Or Ret = "TTLBID" Then 
            Target.Copy 
            Range(Ret & "_SITE")(Target.Row - Range(Ret & "_SITE").Rows(0).Row).PasteSpecial Paste:=xlPasteValues 
        Else 
            MsgBox "Wrong name" 
        End If 
    End If 
     
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,047
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top