Macros

%3CLINGO-SUB%20id%3D%22lingo-sub-1753414%22%20slang%3D%22en-US%22%3EMacros%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1753414%22%20slang%3D%22en-US%22%3EDear%20sir%2C%3CBR%20%2F%3EI%20am%20a%20beginner%20for%20macros.%20I%20want%20to%20create%20a%20macro%20to%20copy%20a%20part%20of%20text%20from%20one%20cell%20and%20append%20it%20to%20the%20text%20in%20another%20cell.%20How%20to%20go%20about%20this%3F%3CBR%20%2F%3EPl%20help.%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1753414%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1753533%22%20slang%3D%22en-US%22%3ERe%3A%20Macros%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1753533%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F823272%22%20target%3D%22_blank%22%3E%40Hda_1957%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20provide%20detailed%20information.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1753582%22%20slang%3D%22de-DE%22%3ESubject%3A%20Macros%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1753582%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F823272%22%20target%3D%22_blank%22%3E%40Hda_1957%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20Mr%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EHans%20Vogelaar%20(%40Hans%20Vogelaar)%3C%2FA%3E%20gave%20you%20as%20advice%2C%20I%20can%20only%20recommend%20it%20to%20you%2C%3C%2FP%3E%3CP%3Eplease%20add%20a%20file%20(without%20sensitive%20data)%20and%20describe%20your%20plan%20on%20it.%3C%2FP%3E%3CP%3EThis%20means%20that%20you%20can%20be%20helped%20more%20quickly%3C%2FP%3E%3CP%3Eand%20the%20best%20possible%20tailored%20solution%20to%20your%20needs%20can%20be%20offered.%3C%2FP%3E%3CP%3ESo%20everyone%20is%20helped...Help%20to%20be%20helped.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E*%20It's%20always%20good%20to%20add%20your%20operating%20system%20and%20Excel%20version.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENevertheless%2C%20here%20is%20a%20little%20VBA%20code%20for%20an%20easy%20copy%20%2F%20paste%20with%20VBA.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPublic%20Sub%20Copy_Paste()%0A%20%20%20%20With%20Worksheets(%22Sheet1%22)%0A%20%20%20%20%20%20%20%20.Range(.Cells(1%2C%201)%2C%20.Cells(10%2C%203)).Copy%20Destination%3A%3D.Cells(11%2C%204)%0A%20%20%20%20End%20With%0AEnd%20Sub%0A%0A'Change%20the%20cell%20%2F%20column%20according%20to%20your%20needs.%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20be%20happy%20to%20know%20if%20I%20could%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENikolino%3C%2FP%3E%3CP%3EI%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor
Dear sir,
I am a beginner for macros. I want to create a macro to copy a part of text from one cell and append it to the text in another cell. How to go about this?
Pl help.
8 Replies
Highlighted

@Hda_1957 

Please provide detailed information.

Highlighted

@Hda_1957 

 

As Mr Hans Vogelaar (@Hans Vogelaar) gave you as advice, I can only recommend it to you,

please add a file (without sensitive data) and describe your plan on it.

This means that you can be helped more quickly

and the best possible solution tailored to your needs can be offered.

So everyone is helped...Help to be helped.

 

* It's always good to add your operating system and Excel version.

 

Nevertheless, here is a little VBA code for an easy copy / paste with VBA.

 

Public Sub Copy_Paste()
    With Worksheets("Sheet1")
        .Range(.Cells(1, 1), .Cells(10, 3)).Copy Destination:=.Cells(11, 4)
    End With
End Sub

'Change the cell / column according to your needs.

 

I would be happy to know if I could help.

 

Nikolino

I know I don't know anything (Socrates)

Highlighted

@Hans Vogelaar 

Thanks Hans for your reply.

 ABC
1Krishna Yadav  
2  Rama 

I wanted to create a Macro to cut/copy text  "Krishna" from cell A1 and paste and append it to "Rama" in cell say C2, to make it "Rama Krishna" in cell C2.

That is the only requirement.

I think I have made my problem clear.

Expect solution.

Regards, 

Hemant

Highlighted

@Nikolino 

Dear Nikolino, Thanks for reply.

 

 ABC
1Krishna Yadav  
2  Rama 

I wanted to create a Macro to cut/copy text  "Krishna" from cell A1 and paste and append it to "Rama" in cell say C2, to make it "Rama Krishna" in cell C2.

That is the only requirement.

I think I have made my problem clear.

Expect solution.

Regards, 

Hemant

Highlighted

@Hda_1957 

For example:

Sub MoveText()
    Dim strText As String
    strText = "Krishna"
    Range("A1").Value = Trim(Replace(Range("A1").Value, strText, ""))
    Range("C2").Value = Range("C2").Value & " " & strText
End Sub
Highlighted

@Hda_1957 

 

Thank you for the feedback

 

No problem, I just pointed it out to you so that you should get the best possible solution.

So Please do not misunderstand my contribution.

 

So far i see Mr.@Hans Vogelaar  give you a solution.
If you like Mr. @Hans Vogelaar  solution, please mark it with a like or as the best answer to Mr. @Hans Vogelaar  contribution,
it will be beneficial to more Community members reading here.

 

 

Thank you for your understanding and patience.

 

Nikolino

I know I don't know anything (Socrates)

Highlighted

@Hans Vogelaar

Dear Hans,

Thanks for your interest in my problem.

Your solution is working. But it moves the text "krishna" only. It works every where wherever there is text "Krishna". But I want to move the word which I select after going to any particular cell in the sheet. It can be any word. Explained further below.

 ABC
1Krishna Yadav Rama 
2satish pulekar jerry
3john dsouza Kamat

When I will go to cell A1 and select "Krishna" and press the shortcut key for the macro, it should cut "Krishna" and cell C1 should become "Rama Krishna".

Similarly, 

When I go to cell A2 and select "pulekar" and press the shortcut key for the macro, it should cut "pulekar " and cell C2 should become "jerry pulekar".

When I go to cell A3 and select "john" and press the shortcut key for the macro, it should cut "john" and cell C3 should become "Kamat".

I have to do such job for about 500 cells which are discontinuous. ( separated from each other)

Regards,

Hemant

 

Highlighted

@Hda_1957 

That is not possible. When you select a word in a cell, Excel is in edit mode. Macros cannot be run while Excel is in edit mode.

We could change the macro to prompt for the word to move. Would that be OK?