Macro to Fill Two Columns

MikeG

Well-known Member
Joined
Jul 4, 2004
Messages
845
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
In my spreadsheet I have two named ranges. One is "User_Name" and the other is "Status"

I would like to create a macro (connected to the shortcut key Ctrl x) so that when the user presses Control x, then no matter what cell he or she is in, the macro will paste the value of "User_Message" in the current cell, and then paste the value of "Status" in the next column to the right. When the action is over, I want the user to still be in the same cell - i.e. I do not want them to end up in the adjacent column.

Thanks!

MikeG
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Like this
Code:
Sub InsertText()
    With ActiveCell
        .Value = "User_Message"
        .Offset(0, 1).Value = Range("Status").Cells(1,1).Value
    End With
End Sub
 
Upvote 0
Like this
Code:
Sub InsertText()
    With ActiveCell
        .Value = "User_Message"
        .Offset(0, 1).Value = Range("Status").Cells(1,1).Value
    End With
End Sub

Brilliant! Works like a dream.

Thanks,

MikeG
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

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