ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Writing (https://www.excelbanter.com/excel-programming/327804-macro-writing.html)

DFIChris

Macro Writing
 
I canNOT figure out Visual Basic Language. All I want my macro to do is to
go to the end of the first line, delete the second line, cut the third line,
past the third line in the cell to the right of the cell I'm editing, and
then go to the cell below the cell I was editing.

When I record this macro it only works in the EXACT cells I edited, not in
any other cells.

Oh help, please.


Don Guillett[_4_]

Macro Writing
 
As always post your macro for comments. By "line", do you mean row?

--
Don Guillett
SalesAid Software

"DFIChris" wrote in message
...
I canNOT figure out Visual Basic Language. All I want my macro to do is

to
go to the end of the first line, delete the second line, cut the third

line,
past the third line in the cell to the right of the cell I'm editing, and
then go to the cell below the cell I was editing.

When I record this macro it only works in the EXACT cells I edited, not in
any other cells.

Oh help, please.




DFIChris

Macro Writing
 
Don, Thank you for responding!!!

No, by line I mean a line of text in a cell which has three lines of text,
separated by "Alt Enter."

I've pasted my macro below. Sorry, I should have thought of doing that from
the start. See where the selection names specific text in the cell and the
ranges are specific cells names? I'm working toward a generic cut and paste
macro that I can use down a column of roughly 120 rows.

Sub Macro5()
'
' Macro5 Macro
' Macro recorded 4/20/2005 by CC Dietrich
'
' Keyboard Shortcut: Ctrl+j
'
ActiveCell.FormulaR1C1 = _
"Danai Tsapikidou
------------------ "
With ActiveCell.Characters(Start:=1, Length:=77).Font
.Name = "Tahoma"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("P3").Select
ActiveSheet.Paste
Range("O4").Select
End Sub




"Don Guillett" wrote:

As always post your macro for comments. By "line", do you mean row?

--
Don Guillett
SalesAid Software

"DFIChris" wrote in message
...
I canNOT figure out Visual Basic Language. All I want my macro to do is

to
go to the end of the first line, delete the second line, cut the third

line,
past the third line in the cell to the right of the cell I'm editing, and
then go to the cell below the cell I was editing.

When I record this macro it only works in the EXACT cells I edited, not in
any other cells.

Oh help, please.





Don Guillett[_4_]

Macro Writing
 
try this

Sub findandmovetext()
v1 = InStr(ActiveCell, Chr(10))
v2 = InStr(v1 + 1, ActiveCell, Chr(10))
ActiveCell.Offset(, 1) = Right(ActiveCell, Len(ActiveCell) - v2)
ActiveCell.Value = Left(ActiveCell, v1 - 1)
End Sub


--
Don Guillett
SalesAid Software

"DFIChris" wrote in message
...
Don, Thank you for responding!!!

No, by line I mean a line of text in a cell which has three lines of text,
separated by "Alt Enter."

I've pasted my macro below. Sorry, I should have thought of doing that

from
the start. See where the selection names specific text in the cell and

the
ranges are specific cells names? I'm working toward a generic cut and

paste
macro that I can use down a column of roughly 120 rows.

Sub Macro5()
'
' Macro5 Macro
' Macro recorded 4/20/2005 by CC Dietrich
'
' Keyboard Shortcut: Ctrl+j
'
ActiveCell.FormulaR1C1 = _
"Danai Tsapikidou
------------------ "
With ActiveCell.Characters(Start:=1, Length:=77).Font
.Name = "Tahoma"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("P3").Select
ActiveSheet.Paste
Range("O4").Select
End Sub




"Don Guillett" wrote:

As always post your macro for comments. By "line", do you mean row?

--
Don Guillett
SalesAid Software

"DFIChris" wrote in message
...
I canNOT figure out Visual Basic Language. All I want my macro to do

is
to
go to the end of the first line, delete the second line, cut the third

line,
past the third line in the cell to the right of the cell I'm editing,

and
then go to the cell below the cell I was editing.

When I record this macro it only works in the EXACT cells I edited,

not in
any other cells.

Oh help, please.







Don Guillett[_4_]

Macro Writing
 
for multiple cells in a selected range

Sub findandmovetextinrange()
For Each c In Selection
v1 = InStr(c, Chr(10))
v2 = InStr(v1 + 1, c, Chr(10))
c.Offset(, 1) = Right(c, Len(c) - v2)
c.Value = Left(c, v1 - 1)
Next c
End Sub

--
Don Guillett
SalesAid Software

"DFIChris" wrote in message
...
Don, Thank you for responding!!!

No, by line I mean a line of text in a cell which has three lines of text,
separated by "Alt Enter."

I've pasted my macro below. Sorry, I should have thought of doing that

from
the start. See where the selection names specific text in the cell and

the
ranges are specific cells names? I'm working toward a generic cut and

paste
macro that I can use down a column of roughly 120 rows.

Sub Macro5()
'
' Macro5 Macro
' Macro recorded 4/20/2005 by CC Dietrich
'
' Keyboard Shortcut: Ctrl+j
'
ActiveCell.FormulaR1C1 = _
"Danai Tsapikidou
------------------ "
With ActiveCell.Characters(Start:=1, Length:=77).Font
.Name = "Tahoma"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("P3").Select
ActiveSheet.Paste
Range("O4").Select
End Sub




"Don Guillett" wrote:

As always post your macro for comments. By "line", do you mean row?

--
Don Guillett
SalesAid Software

"DFIChris" wrote in message
...
I canNOT figure out Visual Basic Language. All I want my macro to do

is
to
go to the end of the first line, delete the second line, cut the third

line,
past the third line in the cell to the right of the cell I'm editing,

and
then go to the cell below the cell I was editing.

When I record this macro it only works in the EXACT cells I edited,

not in
any other cells.

Oh help, please.








All times are GMT +1. The time now is 09:31 PM.

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