Avatar of paulshin
paulshinFlag for United States of America

asked on 

Copy contents of current cell, make a small change, and paste it into the next column

I never use VBA but I'd like to make a shortcut to copy some text in cell A1,modify it slightly, and have it appear in B1 .
For example, in column A, I enter a message like: Go Team.
In column B, I put this message in a code snippet: "message":"Go team".
I want the cell in column B to be updated after I exit the cell in Column A.
Can any one help? Any info on how I'd install the code would help as well. I have Excel 2007.
Thank you.
Microsoft Excel

Avatar of undefined
Last Comment
paulshin
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Put this formula in cell B1:

="message:" & A1

Kevin
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of paulshin
paulshin
Flag of United States of America image

ASKER

Savant,

Thank you! That was awesome. I'm almost there.
Can I use the column name "MyColumn" instead of 1? I tried to use a string as the column name but that failed.
Also, I actually need a string like this:
{"message":"good job"}


Avatar of paulshin
paulshin
Flag of United States of America image

ASKER

Zorvek,
Sorry for calling you Savant :)
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
This code will allow a paste of several values at once:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

    Dim Cell As Range
   
    For Each Cell In Target.Cells
        If Not Application.Intersect(Cell, [MyColumn]) Is Nothing Then
            Cell.Offset(0, 1).Value = "{""message"":""" & Cell.Value & """}"
        End If
    Next Cell

End Sub

Kevin
Avatar of paulshin
paulshin
Flag of United States of America image

ASKER

Thank  you! I couldn't get the last one to work so I  just used the column number approach. Still most excellent. I really appreciate the quick, extensive help!
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo