ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   REPEAT NTH ROWS (https://www.excelbanter.com/excel-programming/387934-repeat-nth-rows.html)

Junior728

REPEAT NTH ROWS
 
Hi,

I wish to prompt the user for 2 parameters(M, N) inputs for every 26th row.
This is what i have in my macro but somehow it does not work. Is there any
problem with my coding?

E.g.

Sub Testing( )

M$ = InputBox("RMANO") 'Prompt user for Input
N$ = InputBox("ACCT") 'Prompt user for Input

Dim LstRow As Integer
Dim NwRow As Integer
Dim NthRow As Integer

'To Repeat This every 26 lines from currentrow
NthRow = 25
LstRow = Cells.SpecialCells(xlLastCell).Row

Do Until ActiveCell.Row LstRow
ActiveCell = Cells(3, 14).Select
ActiveCell.Offset(NwRow, 0).Select
M$ = Cells(3, 14).value 'First parameter in Column M,
N$ = Cells(3, 11).value Second parameter in Column N
NwRow = NwRow + 1
ActiveCell.Offset(NthRow - 1, 0).Select
Loop

End Sub

JLGWhiz

REPEAT NTH ROWS
 
I wish to prompt the user for 2 parameters(M, N) inputs for every 26th row.
This is what i have in my macro but somehow it does not work. Is there any
problem with my coding?

E.g.

Sub Testing( )

M$ = InputBox("RMANO") 'Prompt user for Input
N$ = InputBox("ACCT") 'Prompt user for Input

Dim LstRow As Integer
Dim NwRow As Integer
Dim NthRow As Integer

'To Repeat This every 26 lines from currentrow
NthRow = 25
LstRow = Cells.SpecialCells(xlLastCell).Row

Do Until ActiveCell.Row LstRow
Cells(3, 14).Select
ActiveCell.Offset(NwRow, 0).Select
'If you want cell(3, 14) Or Range("N3") to equal the
'M$ value from the InputBox function then:

Cells(3, 14) = M$
'Same for N$:
Cells(3, 11) = N$ 'Only this puts it in Range("K3")
'Cells(3, 13) woud be Range("M3")

M$ = Cells(3, 14).value 'First parameter in Column M,
N$ = Cells(3, 11).value Second parameter in Column N

'Don't know what the NwRow means. There is no starting value.
NwRow = NwRow + 1

ActiveCell.Offset(NthRow - 1, 0).Select
Loop

End Sub


If you can think this over and repost with a more consitent
description of what you need, I'm sure we can fix you up. This
description and the sample code are a little confusing.




"Junior728" wrote:

Hi,

I wish to prompt the user for 2 parameters(M, N) inputs for every 26th row.
This is what i have in my macro but somehow it does not work. Is there any
problem with my coding?

E.g.

Sub Testing( )

M$ = InputBox("RMANO") 'Prompt user for Input
N$ = InputBox("ACCT") 'Prompt user for Input

Dim LstRow As Integer
Dim NwRow As Integer
Dim NthRow As Integer

'To Repeat This every 26 lines from currentrow
NthRow = 25
LstRow = Cells.SpecialCells(xlLastCell).Row

Do Until ActiveCell.Row LstRow
ActiveCell = Cells(3, 14).Select
ActiveCell.Offset(NwRow, 0).Select
M$ = Cells(3, 14).value 'First parameter in Column M,
N$ = Cells(3, 11).value Second parameter in Column N
NwRow = NwRow + 1
ActiveCell.Offset(NthRow - 1, 0).Select
Loop

End Sub



All times are GMT +1. The time now is 10:27 PM.

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