samanthareed2012
New Member
- Joined
- May 2, 2014
- Messages
- 9
Hi All,
I’m a newbie to VBA, but I have managed (with the help of some coworkers and Google) to put together a code to make a table and fill the cells with appropriate testing information.
The code I have written has an if statement and it’s supposed to go to a block and then resume where it left off, but it just skips cells that I need it to pull data from. Please help! Thank you in advance for all your help!
My code is below:
I’m a newbie to VBA, but I have managed (with the help of some coworkers and Google) to put together a code to make a table and fill the cells with appropriate testing information.
The code I have written has an if statement and it’s supposed to go to a block and then resume where it left off, but it just skips cells that I need it to pull data from. Please help! Thank you in advance for all your help!
My code is below:
Code:
Dim c As Range
Dim variable As String
Dim VarDes As String
Dim DataType As String
Dim ResponseType As String
Dim wordTable As Object
Dim wordRange As Object
Dim wordDocument As Object
Dim VarID As String
Dim Des As String
Dim datatypevalue As String
Dim Section As String
Dim ResponseOptions As String
Dim resopvalue As String
Dim Dec As String
Dim DecVal As String
Dim i As Integer
Dim wordCount As Integer
Dim goToBlock As Integer
Dim numCells As Long
'Initialize counter for the word table
wordCount = 1
'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
DataType = "T" & CStr(i)
datatypevalue = Range(DataType).Value
ResponseType = "N" & CStr(i)
datatypevalue = Range(ResponseType).Value
Section = "F" & CStr(i)
ResponseOptions = "P" & CStr(i)
resopvalue = Range(ResponseOptions).Value
If InStr(Range(ResponseType).Value, "single-select") Then
goToBlock = 1
ElseIf InStr(Range(DataType).Value, "ST") 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 = "Enter 3999 numeric, character, and special character values"
wordTable.Cell(wordCount, 5).Range.Text = "Input Accepted"
1:
ElseIf InStr(Range(ResponseType).Value, "single-select") 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 = "verify all drop down values are present:" & Chr(10) & resopvalue
wordTable.Cell(wordCount, 5).Range.Text = "Values present"
Resume Next