coconutxyz
New Member
- Joined
- Feb 26, 2015
- Messages
- 14
[FONT="]i have searched a bit and all i get doesn't really suit what i needed.[/FONT]
[FONT="]Totally new to VBA but what i am trying to achieve is insert a new row below(either highlighting the whole row or just a cell), copy everything above (format, formula, conditional formatting) and then delete content in specific column(E:K) of the newly created row.[/FONT]
[FONT="]Thanks guys![/FONT]
[FONT="]I have this code available and it does clear the content of specific column but i do not want to manually key in the row number.[/FONT]
<code style="font-family: "Courier New", courier, monospace; margin: 0px 2px; padding: 15px; border: 0px; background-color: transparent; border-radius: 2px; word-break: normal; display: block; font-size: 1em; line-height: 16px; overflow: auto;">Sub Insert()
Dim varUserInput As Variant
varUserInput = InputBox("Enter Row Number where you want to
add a row:", _
"What Row?")
If varUserInput = "" Then Exit Sub
RowNum = varUserInput
Rows(RowNum & ":" & RowNum).Insert Shift:=xlDown
Rows(RowNum - 1 & ":" & RowNum - 1).Copy Range("A" &
RowNum)
Dim x As String
x = "E" & varUserInput & ":" & "k" & varUserInput
Range(x).ClearContents
End Sub</code>
[FONT="]Totally new to VBA but what i am trying to achieve is insert a new row below(either highlighting the whole row or just a cell), copy everything above (format, formula, conditional formatting) and then delete content in specific column(E:K) of the newly created row.[/FONT]
[FONT="]Thanks guys![/FONT]
[FONT="]I have this code available and it does clear the content of specific column but i do not want to manually key in the row number.[/FONT]
<code style="font-family: "Courier New", courier, monospace; margin: 0px 2px; padding: 15px; border: 0px; background-color: transparent; border-radius: 2px; word-break: normal; display: block; font-size: 1em; line-height: 16px; overflow: auto;">Sub Insert()
Dim varUserInput As Variant
varUserInput = InputBox("Enter Row Number where you want to
add a row:", _
"What Row?")
If varUserInput = "" Then Exit Sub
RowNum = varUserInput
Rows(RowNum & ":" & RowNum).Insert Shift:=xlDown
Rows(RowNum - 1 & ":" & RowNum - 1).Copy Range("A" &
RowNum)
Dim x As String
x = "E" & varUserInput & ":" & "k" & varUserInput
Range(x).ClearContents
End Sub</code>