Page 1 of 1

[Solved] Copy visible cells and paste values

PostPosted: Sat Nov 17, 2018 8:36 pm
by Math
greetings

         I'm searching for a macro to copy the cells that have been filtered into Auto Filter (Visible cells), and Paste Values into another worksheet

         Problem description :

         in worksheet1 has Auto Filter from column A to column Z

         you need to copy the Visible filtered cells from column A to column E and paste only the values in the first empty cell of column A in worksheet2

         return to worksheet1 and copy the Visible filtered cells from column I to column L and paste only the values in the first empty cell of column F in worksheet2

         go back to worksheet1 and copy the Visible filtered cells from column U to column W and paste only the values in the first empty cell of column J in worksheet2

         then go back to the worksheet1 and undo all filters, ie Clear All Filters


hugs

Re: Copy visible cells and paste values into another workshe

PostPosted: Sat Nov 17, 2018 8:59 pm
by Villeroy

Re: Copy visible cells and paste values into another workshe

PostPosted: Sat Nov 17, 2018 10:02 pm
by Math
thanks for the support link suggested, unfortunately I could not adapt to my problem

I found other support links:

http://document-foundation-mail-archive ... 64486.html

https://forum.openoffice.org/en/forum/v ... 20&t=58810


unfortunately I also could not adapt to my problem



hugs

Re: Copy visible cells and paste values into another workshe

PostPosted: Sun Nov 18, 2018 12:48 am
by Villeroy
learn how to program

Re: Copy visible cells and paste values into another workshe

PostPosted: Mon Nov 19, 2018 12:29 pm
by Math
Friends, if you can help me in building this code, I am grateful now


hugs

Re: Copy visible cells and paste values into another workshe

PostPosted: Mon Nov 19, 2018 2:37 pm
by Zizi64
Friends, if you can help me in building this code, I am grateful now


Please upload your StarBasic code here (together with the API callings, and an ODF type sample file - but not some copied old VBA code), and we will try to help you to fix the bugs in your code.
If there is not any code yet, we can not help you. You must start your project.

Re: Copy visible cells and paste values into another workshe

PostPosted: Mon Nov 19, 2018 4:12 pm
by Villeroy
He has all the StarBasic code that is needed.
Code: Select all   Expand viewCollapse view
Function copyTiledRanges(oDoc,oRanges,oTopLeft, bVal As Boolean)
REM Takes a spreadsheet doc, a SheetCellRanges collection and a SheetCell object
REM when bVal = True, all formulas will be replaced by values.
REM The ranges should be tiled, e.g. adjacent ranges separated by hidden rows and columns
REM Returns the merged target range
[...]
End Function

Re: Copy visible cells and paste values into another workshe

PostPosted: Wed Nov 21, 2018 5:35 am
by Math
I found a VBA code that does in Excel what I need

If you can help me turn to LibreOffice (BASIC), I am already grateful

source: https://forum.baboo.com.br/index.php?/t ... filtradas/

VBA code

Sub CopyFilter()

Dim rng As Range
Dim rng2 As Range

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng2 Is Nothing Then
MsgBox "No data to copy"
Else
Worksheets("Plan2").Cells.Clear
Set rng = ActiveSheet.AutoFilter.Range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Plan2").Range("A1")
End If

ActiveSheet.ShowAllData

End Sub

Re: Copy visible cells and paste values into another workshe

PostPosted: Wed Nov 21, 2018 8:18 am
by Zizi64
If you can help me turn to LibreOffice (BASIC), I am already grateful

It is not possible to achieve with some pure StarBasic commands and statements. You must study and use the API functions of the AOO/LO.
API : Application Programming Interface.
Please download and read Andrew Pitonyak's free macro books.

(This forum is NOT a free macro translation service!)

Re: Copy visible cells and paste values into another workshe

PostPosted: Wed Nov 21, 2018 2:51 pm
by Villeroy
This is about real programming. You do not even know VBA, so you are completely lost when confronted with a task that can not be solved by means of copy/paste or macro recording. You are by far not the only "VBA expert" of the same calibre and we are no human macro recorders. I've got work to do.

Re: Copy visible cells and paste values into another workshe

PostPosted: Fri Nov 23, 2018 6:24 pm
by Math
[Solved]

Thank you for the contributions of all the friends who helped


hugs

Re: [Solved] Copy visible cells and paste values

PostPosted: Fri Nov 23, 2018 9:04 pm
by Villeroy
You don't share your solution with the public?