adding question numbers

ashleywanless

Board Regular
Joined
Aug 4, 2009
Messages
158
Hi,

I have a macro which produces a worksheet of specific questions according to what criteria a user choses on a userform. It then copies this data into a new tab. There are 3 columns, Question Number, Question and Evidence.

My problem is that because the data copied is a mere extract of a much larger question set the question numbers in column A do not run concurrently. e.g 1,2,5,6,7,9,10 etc etc. I need to find a way of making these numbers in the extract sheet run concurrently. This can't be a simple as typing 1 in cell A3, 2 in cell A4, 3 in cell A5 then sending down the page as the copied data contains grey header lines. These do not have a question number in column A instead they have a H.

Can anyone think of how to do this? so that the numbers in cells A3 onwards run concurrently unless the Value H is anywhere in column A, in which case the H should be left and the next cell should continue the numbering sequence?

Thanks

Ashley
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
If I understand correctly, try

Code:
Sub test()
Dim FinalRow As Long
FinalRow = Range("B" & Rows.Count).End(xlUp).Row
With Range("A3:A" & FinalRow)
    .Value = Evaluate("ROW(" & .Address & ")-2")
End With
End Sub
 
Upvote 0
Hi thanks for the reply.

The code works but doesn't take into account that if column
C has the value H it should miss that row and put the next sequential
number in the next row
 
Upvote 0
Try

Code:
Sub test()
Dim FinalRow As Long, i As Long, j As Integer
FinalRow = Range("B" & Rows.Count).End(xlUp).Row
For i = 3 To FinalRow
    If Range("C" & i).Value <> "H" Then
        j = j + 1
        Range("A" & i).Value = j
    End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top