I need help autofilling my filtered cells

my macro is below. I need to fil down CPG_HECTOR to the first filtered cell to the last filtered cell in the data. What line of code can I add?

  Sub Macro9()
'

 Workbooks.Open "Z:\CPG\CPG Roswell\IS Dispatch\Dispatch report.xlsx"
Dim sh As Worksheet
Set sh = Worksheets("NJ")

'

'
    Windows("Dispatch report.xlsx").Activate
    ActiveSheet.Range("A1").AutoFilter Field:=4, Criteria1:="="

 ActiveSheet.Range("A1").AutoFilter Field:=13, Criteria1:="BUSINESS SPECIFIC SOFTWARE~43230000"
   ActiveSheet.AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 4).Select
   ActiveCell.Formula = "CPG_HECTOR"

This question doesn’t seem to be related to Writer. So please retag probably calc and macro. Also to guide contributors in their answers, mention OS name, LO version and save format. Apparently, the save format is .xlsx. Be aware that most solutions won’t be stable and reliable when save format is not native, i.e. .ods.

Thank you, i have updated it

Where are the required information: OS name, LO version and save format?

I have no idea what you are asking i am sorry. i just need help with this macro

My domain of competence is Writer. So you need to attract attention of Calc and, most important macro, gurus. Hence my request to change the tags.
OS name is Windows “y”, MacOS “z” or Linux distro “x” version “w”; LO version is reported by Help>About LO (report all the numbers as there are many differences between releases, mainly bug fixes); save format id .xlsx, .ods or maybe something else.
All these details will help contributors to give ad hoc advice.

Welcome!
As far as I could understand, you are trying to solve the following problem:
open an Excel workbook named “Dispatch report.xlsx”, which is located on a network drive, and in the table on a sheet named “NJ” enter the term “CPG_HECTOR” in the fourth column of the line for which there is nothing in the fourth column (or written sign “=”?), and in the 13th column there is the text “BUSINESS SPECIFIC SOFTWARE~43230000”.

Have I correctly deciphered the actions of your code?

Yes correct, I filtered column 14 for business. In column 4 I pasted CPG_Hector. Now I need to drag CPG_Hector down to all the remaining results from my filter in column 14.

Let’s start by throwing away your code and forget about it. All constructs that were used in this macro are guided by Excel architecture and VBA methods. Calc is not Excel, everything is done differently here.

First of all - opening a spreadsheet. You can use several methods, they are described in the Wiki
I recommend using the
Function OpenDocument(DocPath as String, Args(), Optional bDisposable as Boolean)
from the Tools standard library: load the library, make sure the desired file exists at the specified location, try opening the desired file, verify that the file actually opened. In Basic it is written like this:

   GlobalScope.BasicLibraries.LoadLibrary("Tools")
   sFileURL = ConvertToURL("Z:\CPG\CPG Roswell\IS Dispatch\Dispatch report.xlsx")
   If Not FileExists(sFileURL) Then Exit Sub
   oDoc = OpenDocument(sFileURL, Array())
   If IsNull(oDoc) Then Exit Sub

Getting the desired sheet is also described in Wiki

   oSheet = oDoc.Sheets.getByName("NJ")

Now let’s think about whether you need an Autofilter? Hint: You don’t need an AutoFilter for this task. Second tip: AutoFilter is not needed at all to work, it gives more problems than convenience.
And how to complete the task without it?
For example, you can go through all the lines on the sheet, reading the values of each cell in the 13th column and checking its contents for the desired text - if the desired row is found, check the contents of the 4th cell of this row and, if necessary, enter the desired word. This will work. But! This will work VERY SLOWLY. It is better to use another method: read the entire table into an array at once, loop through the elements of the array and then write it all back to the table at a time.

   nLastRow = GetLastUsedRow(oSheet)
   a13 = oSheet.getCellRangeByPosition(12,0,12,nLastRow).getDataArray()
   aRange = oSheet.getCellRangeByPosition(3,0,3,nLastRow)
   a4 = aRange.getDataArray()
   For i = 1 To nLastRow
      If a13(i)(0) = "BUSINESS SPECIFIC SOFTWARE~43230000" Then
         If a4(i)(0) = "=" Then If a4(i)(0) = "CPG_HECTOR"
      EndIf
   Next i
   aRange.setDataArray(a4)

I hope these explanations are enough for you to be able to write the whole subroutine?

1 Like

I am using excel

And why do you ask HERE?

I thought this was a place I could ask. Was I mistaken?

It depends on the question.
LibreOffice can open many kinds of files created with Excel (or generally MS Office software), and there is a wide range of reliable interoperability. LibreOffice even supports the use of constructs from VBA (Excel-VBA e.g.) to some degree. It surely is NOT a tool to develop VBA macros. And this site is made to support users of LibreOffice and run by the non-commercial DocumentFoundation.
@JohnSUN is an extremely knowledgeable and friendly helper. He took a lot of time to give you a little programming course. But he is not an Excel expert, and certainly not contracted by MS. They should have enough billions to get support for their stuff up and running.

2 Likes

i definitely appreciate the knowledge. i didn’t know. i am sorry for the inconvenience. i am just trying to build something at work. I will look somewhere else

Please remove tag math. Within the LO suite, this tag marks issues with the Math formula editor.

1 Like

LibreOffice is a software where i can build reports?

LibreOffice comes (in a roughly monolithic architecture) with the components
Writer (text processor)
Calc (spreadsheet software)
Math (creation of mathematical formulas for display)
Draw (vector graphics)
Impress (using many Draw features; presentations similar to ppt)
and
Base (making connections to external Databases; also supporting two flavors of file-embedded databases, and …)
Reports? Database forms can be created in Writer documents or in spreadsheets e.g. (but I’m not an expert insofar).