ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro - Inserting text to a cell already containg text (https://www.excelbanter.com/excel-discussion-misc-queries/121759-macro-inserting-text-cell-already-containg-text.html)

Dileep Chandran

Macro - Inserting text to a cell already containg text
 
Hello everybody,

Is it possible to select a text from B100 of Book1.xls and paste it to
B100 (which already has a text) of Book2.xls?

Assume both books are open.
Assume B100 of Book1 contains "XYZ" and B100 of Book 2 contains "ABCD"
So the macro should run so as to change B100 of Book 2 "ABCD - XYZ"

Can anyone help?
Thanks and Regards
-Dileep


Ian

Macro - Inserting text to a cell already containg text
 
Range("B100").Select
Selection.Copy
Windows("Book2").Activate
Range("B100").Select
ActiveSheet.Paste

--
Ian
--
"Dileep Chandran" wrote in message
ups.com...
Hello everybody,

Is it possible to select a text from B100 of Book1.xls and paste it to
B100 (which already has a text) of Book2.xls?

Assume both books are open.
Assume B100 of Book1 contains "XYZ" and B100 of Book 2 contains "ABCD"
So the macro should run so as to change B100 of Book 2 "ABCD - XYZ"

Can anyone help?
Thanks and Regards
-Dileep




Gary''s Student

Macro - Inserting text to a cell already containg text
 
Sub dee()
Dim r1 As Range, r2 As Range

Set r1 = Workbooks("Book1").Worksheets("Sheet1").Range("B10 0")
Set r2 = Workbooks("Book2").Worksheets("Sheet1").Range("B10 0")

r2.Value = r2.Value & " - " & r1.Value

End Sub



--
Gary's Student


"Dileep Chandran" wrote:

Hello everybody,

Is it possible to select a text from B100 of Book1.xls and paste it to
B100 (which already has a text) of Book2.xls?

Assume both books are open.
Assume B100 of Book1 contains "XYZ" and B100 of Book 2 contains "ABCD"
So the macro should run so as to change B100 of Book 2 "ABCD - XYZ"

Can anyone help?
Thanks and Regards
-Dileep



JMay

Macro - Inserting text to a cell already containg text
 
Isn't this code "replacing" the content of Book2 - cell B100 with XYZ,
not ABCD - XYZ.

How bout something more like: (Paste into a std module - Book2
Sub tester()
Windows("Book2").Activate
sTemp = Range("B10").Value
Windows("Book1").Activate
sNew = Range("B10").Value
Windows("Book2").Activate
sCombo = sTemp & " - " & sNew
Range("B10").Value = sCombo
End Sub

HTH



"Ian" wrote in message
:

Range("B100").Select
Selection.Copy
Windows("Book2").Activate
Range("B100").Select
ActiveSheet.Paste

--
Ian
--
"Dileep Chandran" wrote in message
ups.com...
Hello everybody,

Is it possible to select a text from B100 of Book1.xls and paste it to
B100 (which already has a text) of Book2.xls?

Assume both books are open.
Assume B100 of Book1 contains "XYZ" and B100 of Book 2 contains "ABCD"
So the macro should run so as to change B100 of Book 2 "ABCD - XYZ"

Can anyone help?
Thanks and Regards
-Dileep



CLR

Macro - Inserting text to a cell already containg text
 
Hi Gary"s Student...........that code is most cool.........

I would also suggest that the OP also include a line to save the Book2.xls
file after making the change, otherwise if it is inadvertantly closed, the
change will be lost.....

Vaya con Dios,
Chuck, CABGx3




"Gary''s Student" wrote:

Sub dee()
Dim r1 As Range, r2 As Range

Set r1 = Workbooks("Book1").Worksheets("Sheet1").Range("B10 0")
Set r2 = Workbooks("Book2").Worksheets("Sheet1").Range("B10 0")

r2.Value = r2.Value & " - " & r1.Value

End Sub



--
Gary's Student


"Dileep Chandran" wrote:

Hello everybody,

Is it possible to select a text from B100 of Book1.xls and paste it to
B100 (which already has a text) of Book2.xls?

Assume both books are open.
Assume B100 of Book1 contains "XYZ" and B100 of Book 2 contains "ABCD"
So the macro should run so as to change B100 of Book 2 "ABCD - XYZ"

Can anyone help?
Thanks and Regards
-Dileep



Dileep Chandran

Macro - Inserting text to a cell already containg text
 

Thanks, JMay for your help.....


Ian

Macro - Inserting text to a cell already containg text
 
Correct. Sorry, I misread the OP.

--
Ian
--
"JMay" wrote in message
...
Isn't this code "replacing" the content of Book2 - cell B100 with XYZ, not
ABCD - XYZ.

How bout something more like: (Paste into a std module - Book2
Sub tester()
Windows("Book2").Activate
sTemp = Range("B10").Value
Windows("Book1").Activate
sNew = Range("B10").Value
Windows("Book2").Activate
sCombo = sTemp & " - " & sNew
Range("B10").Value = sCombo
End Sub

HTH



"Ian" wrote in message
:

Range("B100").Select
Selection.Copy
Windows("Book2").Activate
Range("B100").Select
ActiveSheet.Paste

--
Ian
--
"Dileep Chandran" wrote in message
ups.com...
Hello everybody,

Is it possible to select a text from B100 of Book1.xls and paste it to
B100 (which already has a text) of Book2.xls?

Assume both books are open.
Assume B100 of Book1 contains "XYZ" and B100 of Book 2 contains "ABCD"
So the macro should run so as to change B100 of Book 2 "ABCD - XYZ"

Can anyone help?
Thanks and Regards
-Dileep






All times are GMT +1. The time now is 06:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com