S
simplysewing
I have a schedule-type table in MS Word with 13 rows (12 months +
label row) , and 32 columns (31 days + label column). The cells for
months with <31 days are blacked out. I want to assign variables to
my starting cell, and ending cell, then count the number of cells that
are blacked out. My idea was assign a variable to the start of the
range (BegRng) and end of the range (EndRng) as the code was placing
text ("R") in cells, then count the black cells with a variable
(tmpCount) between these placement calls. Here's what I tried:
(Start Snip)
BegRng = ActiveDocument.Tables(1).Cell(IRow, ICol).Range
ActiveDocument.Tables(1).Cell(IRow, ICol).Range.Text = "R"
ActiveDocument.Tables(1).Cell(IRow,
ICol).Range.Cells.Shading.Texture = 200
ICol = ICol + 1
EndRng = ActiveDocument.Tables(1).Cell(IRow, ICol).Range
(End Snip)
Sub Count()
Dim tmpCount As Integer, SearchRng As Range
tmpCount = 0
Set SearchRng = ActiveDocument.Tables(1).Cell(BegRng, EndRng).Range
If SearchRng = "R" Then
tmpCount = tmpCount + 1
End If
End Sub
I get an "Type mismatch" error at the Set line. (I left BegRng and
EndRng variables as variant)
Any ideas? TIA for any assistance!
label row) , and 32 columns (31 days + label column). The cells for
months with <31 days are blacked out. I want to assign variables to
my starting cell, and ending cell, then count the number of cells that
are blacked out. My idea was assign a variable to the start of the
range (BegRng) and end of the range (EndRng) as the code was placing
text ("R") in cells, then count the black cells with a variable
(tmpCount) between these placement calls. Here's what I tried:
(Start Snip)
BegRng = ActiveDocument.Tables(1).Cell(IRow, ICol).Range
ActiveDocument.Tables(1).Cell(IRow, ICol).Range.Text = "R"
ActiveDocument.Tables(1).Cell(IRow,
ICol).Range.Cells.Shading.Texture = 200
ICol = ICol + 1
EndRng = ActiveDocument.Tables(1).Cell(IRow, ICol).Range
(End Snip)
Sub Count()
Dim tmpCount As Integer, SearchRng As Range
tmpCount = 0
Set SearchRng = ActiveDocument.Tables(1).Cell(BegRng, EndRng).Range
If SearchRng = "R" Then
tmpCount = tmpCount + 1
End If
End Sub
I get an "Type mismatch" error at the Set line. (I left BegRng and
EndRng variables as variant)
Any ideas? TIA for any assistance!