How to use recorded macro in different cells

[Closed]
Report
Posts
1
Registration date
Monday December 2, 2013
Status
Member
Last seen
December 2, 2013
-
Posts
2809
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 23, 2021
-
Hello,

Kindly help me to resolve this issue,

I want to insert data in 4 different cells each i run my macro

sample data:

Sub Insert()
'
' Insert Macro
'
' Keyboard Shortcut: Ctrl+q
'

ActiveCell.FormulaR1C1 = "Test 1"
Range("A9").Select
iText = ActiveCell.FormulaR1C1 = "Test 2"
Range("A10").Select
ActiveCell.FormulaR1C1 = "Test 3"
Range("A11").Select
ActiveCell.FormulaR1C1 = "Test 4"
Range("D8").Select
ActiveCell.FormulaR1C1 = "Enter Invalid Input"
Range("D9").Select
ActiveCell.FormulaR1C1 = "Enter Invalid Input 3rd time"
Range("D10").Select
ActiveCell.FormulaR1C1 = "Enter No Input 1st and 2nd Time"
Range("D11").Select
ActiveCell.FormulaR1C1 = "Enter No input 3rd Time"
Range("D8:D11").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("D:D").ColumnWidth = 24.57
Rows("11:11").RowHeight = 44.25
Rows("11:11").EntireRow.AutoFit
Range("C9").Select
Columns("D:D").EntireColumn.AutoFit
Rows("8:8").EntireRow.AutoFit
Rows("9:9").EntireRow.AutoFit
Rows("10:10").Select
Rows("10:10").EntireRow.AutoFit
Range("A8:M11").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("I10").Select
End Sub

1 reply

Posts
2809
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 23, 2021
484
Hi Saiselvak88,

Not clear what you are trying to achieve. Please re-explain with more details.

Best regards,
Trowa