Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select One Field in a Worksheet Table

Status
Not open for further replies.

grnzbra

Programmer
Mar 12, 2002
1,273
US



I have two worksheets, PM Template and PM Schedule. The template worksheet has records about different maintenance schedules. The schedule worksheet has records for various pieces of equipment and a field containing the name of the template associated with that piece of equipment. The code below is part of a procedure activated when a hyperlink on PM Template worksheet is selected. The name of the PM Template is picked up in the PMTempName variable and is used to find and delete any rows in the table on PM Schedule worksheet containing that name. It works very nicely. However, I don't want to delete the record; I only want to clear the PM Template Name field in the table on the PM Schedule worksheet (This code is based on another pair of sheets in which I do want to delete the entire row.) The name of the field in the schedule table is "PM Template Name". It is the "G" column on the worksheet. How can I select only this one field to clear?
Code:
  'If there is warranty data, loop through it to find and delete warranties related to this equipment item
            If Not PMScheduleList.DataBodyRange Is Nothing Then
                Do
                    Set PMScheduleRow = PMScheduleList.DataBodyRange.Find(PMTempName, , xlFormulas) 'xlFormulas finds hidden
                    If Not PMScheduleRow Is Nothing Then
                        If PMScheduleList.DataBodyRange.Rows.Count > 1 Then
                            PMSchedule.Unprotect
                            PMScheduleWorkSheet.Rows(PMScheduleRow.row).Delete
                            PMSchedule.Protect
                        Else
                            PMScheduleList.DataBodyRange.Clear
                        End If
                    End If
                Loop While Not PMScheduleRow Is Nothing
            End If
 
Hi,

VBA code questions are best addressed in forum707. This forum deals with application native functionality.

That aside, I'd use Intersect().ClearContents, that is the intersection of [PM Template Name] and PMScheduleRow.

I'm assuming that you're using Structured Tables.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Thank you.

I will post this there. In the meantime, I will try your suggestion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top