Hi Vrunda ,
Yes , the named range Party_List has been defined as :
=Sheet1!$A$4:INDEX(Sheet1!$A:$A,COUNTA(Sheet1!$A:$A)+1)
Essentially this is a list of all the vendors / customers.
I had originally defined the VBA variable partylist as a static range A3:A500 ; this why I had commented Change as required. Now , since a dynamic named range called Party_List has been defined within the worksheet , the VBA itself will not need to be changed.
If your sheet name is different from Sheet1 , you will have to change the following statement :
Sheets("Sheet1").Activate
Other than this , I don't think you will need to change anything more.
Deleting rows after A5 will not create any problem , since if rows are deleted , the named range will adjust itself automatically. The same goes for using cut-paste commands.
The following statement :
=Sheet1!$A$4:INDEX(Sheet1!$A:$A,COUNTA(Sheet1!$A:$A)+1)
is a standard way of defining a dynamic named range i.e. the range expands to accommodate any fresh data that you might enter. The starting point is Sheet1!$A$4 ; the COUNTA(Sheet1!$A:$A) function counts the number of cells in column A , which have some data in them e.g. in your worksheet at present , this will return the number 16 , since the cells A1 through A17 , except cell A2 , have data in them. When we add 1 to this ( +1 ) , we get 17 , which is the row number of the last cell in column A which has data. Thus , we are defining the range Sheet1!$A$4:$A$17.
If you now add data in A18 , the COUNTA function will return 17 ( instead of the earlier 16 ) , and the range will now become Sheet1!$A$4:$A$18. Thus , without your having to do anything , the range has automatically adjusted its definition to include the new row of data. The only thing you have to ensure is that between the first row of data , say A4 , and the last row of data , say A17 , there are no blank cells , because the COUNTA function will return a wrong cell address for the last cell with data , in the formula for the named range.
In case you face any problems , please get back to me.
Remember that the +1 in the named range definition is because A2 is blank at present ; in case you enter something in this cell , or you delete this row altogether , then you will have to remove the +1 from the definition of the named range.
Narayan