Macro help!! Almost there..

dlhirving

New Member
Joined
Oct 25, 2006
Messages
6
this is my first 'custom' macro. and here is what I need it do do:
1)user prompted to select range of cells => works fine
2)macro then inserts cells to the right of the range => works fine
2)apply formula in those inserted cells to put brackets before and after cell contents => works fine
3)copy the new range and paste special (values) over the original range => works fine
4)I cannot select the inserted range to delete it and bring everything back together
--> I have tried a ton of offset stuff and Range stuff but I can't get them selected!!!!!!!

here is what I have -- any help would be awesome!!!

Code:
Sub bracket()

    Dim UserRange As Range
    Dim PasteRange As Range
    
    Prompt = "Select a range for ...."
    Title = "Select range"
'   Display the Input Box
    On Error Resume Next
    Set UserRange = Application.InputBox( _
        Prompt:=Prompt, _
        Title:=Title, _
        Default:=ActiveCell.Address, _
        Type:=8) 'Range selection

    If UserRange Is Nothing Then
        MsgBox "Canceled."
    Else
    UserRange.Select
    Selection.Insert Shift:=xlToRight
    For Each UserRange In Selection
         UserRange.FormulaR1C1 = "=""(""&RC[1]&"")"""
    Next
    UserRange.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Application.CutCopyMode = False
    
    UserRange.Offset(3, 0).Select
    Selection.Font.Bold = True
    ' this is where I need to select the inserted range so I can delete it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    'Application.CutCopyMode = False
   ' Selection.Delete Shift:=xlToLeft
    End If
    
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,790
Messages
6,126,914
Members
449,348
Latest member
Rdeane

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