V
victoria.rego
I have a button on my VB form that, when clicked, opens a template
word document with a table, populates the table with values, and
deletes any rows that aren't needed depending on certain checkboxes on
the form and certain cells in an excel document.
For example:
ElseIf Trim(eaExcelApplication.Range("J" & xlsRow)) = "" And
Trim(eaExcelApplication.Range("K" & xlsRow)) = "" Then
With ActiveDocument.Tables(1)
..cell(column:=3, row:=11).Delete wdDeleteCellsEntireRow
This worked fine because I would delete the rows in reverse order so
the row number wouldn't change, however... I've overlooked certain
exceptions that require rows to be deleted. It seems really
inefficient to have an ongoing series of if elseif statements for
every combination of possible scenarios...
I'd like someway of labeling these rows with names (the row headers
for example) so that it won't matter what the row number is, it'll
delete the row with that header.
Is there such a way to do this?
To summarize, right now I tell the application the row number to
delete, but I need to be able to delete these rows no matter what row
number they are. Each row has a row header, so perhaps match the
headers to "section numbers" and write a delete method and pass it the
section number or something?
Thanks,
word document with a table, populates the table with values, and
deletes any rows that aren't needed depending on certain checkboxes on
the form and certain cells in an excel document.
For example:
ElseIf Trim(eaExcelApplication.Range("J" & xlsRow)) = "" And
Trim(eaExcelApplication.Range("K" & xlsRow)) = "" Then
With ActiveDocument.Tables(1)
..cell(column:=3, row:=11).Delete wdDeleteCellsEntireRow
This worked fine because I would delete the rows in reverse order so
the row number wouldn't change, however... I've overlooked certain
exceptions that require rows to be deleted. It seems really
inefficient to have an ongoing series of if elseif statements for
every combination of possible scenarios...
I'd like someway of labeling these rows with names (the row headers
for example) so that it won't matter what the row number is, it'll
delete the row with that header.
Is there such a way to do this?
To summarize, right now I tell the application the row number to
delete, but I need to be able to delete these rows no matter what row
number they are. Each row has a row header, so perhaps match the
headers to "section numbers" and write a delete method and pass it the
section number or something?
Thanks,