samanthareed2012
New Member
- Joined
- May 2, 2014
- Messages
- 9
Hello!
I want my code to loop through the worksheets so I used For each-Next,. but it brings up an error "invalid next control variable reference".
I have more to my code but for space and time saving I have removed the more lengthy parts. Any help would be much appreciated!
Code:
I want my code to loop through the worksheets so I used For each-Next,. but it brings up an error "invalid next control variable reference".
I have more to my code but for space and time saving I have removed the more lengthy parts. Any help would be much appreciated!
Code:
Code:
Dim mysheet As Worksheet
For Each mysheet In ActiveWorkbook.Worksheets
'Counter for Excel worksheet
For i = 1 To numCells
variable = "A" & CStr(i)
Range(variable).Select
VarID = Range(variable).Value
VarDes = "C" & CStr(i)
Des = Range(VarDes).Value
Dec = "U" & CStr(i)
DecVal = Range(Dec).Value
ResponseType = "N" & CStr(i)
datatypevalue = Range(ResponseType).Value
DataType = "T" & CStr(i)
datatypevalue = Range(DataType).Value
Section = "F" & CStr(i)
ResponseOptions = "P" & CStr(i)
resopvalue = Range(ResponseOptions).Value
'Text Areas
If InStr(Range(ResponseType).Value, "textarea") Then
wordTable.Rows.Add
wordCount = wordCount + 1
wordTable.Cell(wordCount, 1).Range.Text = wordCount - 1
wordTable.Cell(wordCount, 2).Range.Text = VarID
wordTable.Cell(wordCount, 3).Range.Text = Des
wordTable.Cell(wordCount, 4).Range.Text = "Leave text field blank"
wordTable.Cell(wordCount, 5).Range.Text = "Accepts input"
wordTable.Rows.Add
wordCount = wordCount + 1
wordTable.Cell(wordCount, 1).Range.Text = wordCount - 1
wordTable.Cell(wordCount, 2).Range.Text = VarID
wordTable.Cell(wordCount, 3).Range.Text = Des
wordTable.Cell(wordCount, 4).Range.Text = "Enter 3999 numeric, character, and special character values"
wordTable.Cell(wordCount, 5).Range.Text = "Input Accepted"
wordTable.Rows.Add
wordCount = wordCount + 1
wordTable.Cell(wordCount, 1).Range.Text = wordCount - 1
wordTable.Cell(wordCount, 2).Range.Text = VarID
wordTable.Cell(wordCount, 3).Range.Text = Des
wordTable.Cell(wordCount, 4).Range.Text = "Enter more than 3999 characters"
wordTable.Cell(wordCount, 5).Range.Text = "Input not accepted"
End If
Next mysheet
Next
wordTable.Rows(1).HeadingFormat = True
WDApp.ActiveDocument.Save
End Sub
Last edited: