0

Good day all

I want to use VBA to avoid the slowness in Excel when moving from one sheet to another. I replace formulas with VBA code. In brief I want to filter a column (A) that has hundreds of words based on the last characters and then use vba code to textjoin them and paste them in one cell. I managed by VBA code to filter them and paste them in another sheet but I want to edit the code to filter the list, textjoin them and paste them to a cell without using formulas. This is the code I used. Thank you

` Sub FilteringByLastCharacter()

Dim FLCretera As String

FLCretera = ThisWorkbook.Worksheets("Searching").Range("A2")
Sheets("WordsList").Select
Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$B12169").AutoFilter Field:=1, Criteria1:="*" & FLCretera
Columns("A:A").Select
Selection.Copy

Sheets("Searching").Select
Range("S1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
Sheets("WordsList").Select
ActiveSheet.Range("$A$1:$B$12169").AutoFilter Field:=1
Sheets("Searching").Select
Range("A1").Select
Application.CutCopyMode = False
Range("A2").Select
End Sub`
  • 1
    Hi and welcome to S.O.. Please note that this is not a free code writing service. you have told us what you want to do, but not what the problem you are facing is... – cybernetic.nomad Oct 12 '22 at 16:33
  • 1
    Side note: It`'s usually a good idea to [avoid suing Select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) in your code. Doing so _may_ help solve some of the problems you currently have – cybernetic.nomad Oct 12 '22 at 16:34

1 Answers1

0
application.displayalerts=false  
application.screenupdating=false

FLCretera = ThisWorkbook.Worksheets("Searching").Range("A2")  
Sheets("WordsList").Select  
Range("A1").Select

''''clear filters 

On error resume next   
activesheet.clearallfilters

''''''find the las cells with inf


uf=ActiveSheet.Columns("A").Find("*", _  
searchorder:=xlByRows, searchdirection:=xlPrevious).Row

''''create filter


ActiveSheet.Range("$A$1:$B" & uf).AutoFilter Field:=1, Criteria1:="*" & FLCretera 
range("A1:B" & uf).copy

'''''
Sheets("Searching").Select

Range("S1").Select

Selection.PasteSpecial Paste:=xlPasteValues


for flag = 1 to uf
'''range("C" & flag) where paste the words for Cells A and B
range("C" & flag)=range("A" & flag)&range("C" & flag)

next flag

Sheets("WordsList").Select

Application.CutCopyMode = False
application.displayalerts=true
application.screenupdating=true

End Sub

sorry, my english is short, but i try to help.
take care

  • It is recommended to try to explain (even a little bit) what your code is doing (and why) in order for other people to be able to better understand your solution. – tur1ng Oct 21 '22 at 12:14