user3669801 - 11 months ago 41

Vb.net Question

I am very new to

`VB Macro`

`Excel`

`excel`

I am trying to

`Copy`

`Range`

`i`

`N`

`Question`

`N`

`"Question"`

`copy`

`Range`

`cell`

`cell`

`column N`

`Column Y`

`Range(i+1, N : i+9, Y)`

`Range`

`eighth cell`

`Column A`

`"Question"`

`Range`

`Range(i+9, A : i+17, A)`

I tried the following code but it does not work. So, I would really appreciate any help regarding this. Following is my code:

`Sub OrganizingQuestion()`

Dim iRow As Integer

Dim que As String

Dim rng As Range

Dim rng2 As Range

For iRow = 1 To Range("N" & "5000").End(xlUp).Row Step 1

If Cells(iRow, 14) = "Question" Then

Set rng = Range("N" & iRow + 1 & ":Y" & iRow + 9)

rng.Copy

End If

If Cells(iRow, 1) = "Question" Then

Set rng2 = Range("A" & iRow + 9 & ":A" & iRow + 18)

rng2.EntireRow.Insert Shift:=xlDown, CopyOrigin:=rng

End If

Next iRow

End Sub

Answer

CopyOrigin is takes an XlInsertFormatOrigin enumeration value. I never use it.

```
Sub OrganizingQuestion()
Dim iRow As Integer
For iRow = 1 To Range("N" & Rows.Count).End(xlUp).Row Step 1
If Cells(iRow, 14) = "Question" And Cells(iRow, 1) = "Question" Then
Range("N" & iRow + 1 & ":Y" & iRow + 9).Copy
Range("A" & iRow + 9 & ":A" & iRow + 18).Insert Shift:=xlDown
End If
Next iRow
End Sub
```

Source (Stackoverflow)