Is there way to reduce a sheet size with 31000 rows for faster seaching by some sort of compressing method?

chazrab

Well-known Member
Joined
Oct 21, 2006
Messages
884
Office Version
  1. 365
Platform
  1. Windows
Title explains. I use the FIND method in a button click code. The button stays depressed an awfully long time before it produces the
results of a search. Other software apps like mine written in C# give instanteous results with exactly the same 31,103 rows across 4 columns.
Want to keep the development in VBA. Learning curve of C# is to complicated.

thx for any suggestions.
ct
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Using arrays can speed up the macro considerably. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Also, use code tags to post the FIND macro you are currently using. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data. Alternately, you could upload a copy of your file (de-sensitized if necessary) to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here.
 
Upvote 0
Using arrays can speed up the macro considerably. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Also, use code tags to post the FIND macro you are currently using. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data. Alternately, you could upload a copy of your file (de-sensitized if necessary) to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here.
Hi mumps, thx for trying to help.
Here's the code that does the work:
Code:
Private Sub cmdFIND_Click()
Sheets("NEWRESULT").UsedRange.ClearContents ' NEWRESULT is the sheet that Find copies the results to
Dim lastrow As Integer
Dim X As String
Dim c As Range
Dim rw As Long
Dim firstAddress As Variant
Dim rowno As Variant
X = Me.TextBox6.Value 'Textbox6 takes any word or string value, i.e., "east", or "the end of all flesh", or "Matthew 24:15" (w/out quotes)
TextBox7.Value = TextBox6.Value
With Worksheets("Sheet2").Range("E1:E31103") 'searches down Sheet2 col E  specified by With of C,D, E and F cols. 
    Set c = .Find(X, LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then
rw = 1
firstAddress = c.Address
Do
Worksheets("Sheet2").Select
c.Select
Range(Cells(c.row, 2), Cells(c.row, 7)).Copy Destination:=Sheets("NEWRESULT").Range("B" & rw)  ' NEWRESULT sheet that Find copies the results to
                rw = rw + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
Else
MsgBox "No value found"
End If
End With
rowno = Sheets("NEWRESULT").Range("B2").End(xlDown).row
lastrow = Sheets("NEWRESULT").Range("B" & Rows.count).End(xlUp).row
TextBox8.Value = lastrow & "  " & "verses found for " & """" & TextBox6.Value & """"
'TextBox3.Value = LastRow & "  " & "verses found for " & TextBox1.Value
Sheets("NEWRESULT").Range("H1").Value = rowno
Sheets("NEWRESULT").Range("I1").Value = X
ListBox1.ListIndex = 0
'Sheets("Sheet3").Select
End Sub

The screenshot below is only a partial view. The code has to search down all 31013 rows and across 5 cols, as mentioned.
The FIND method above is typical and gives the results, but takes way too much time.

re the value of X: 'the value of X can be any string of words
Works but finds ALL instances of any word, even within a word (xlPart).
The code runs great but as mentioned, is way too slow. Autofilter is a little faster, but I still lean toward using Find w vba.

I haven't used xl2BB. I just pasted screenshots below. If you need them in xl2BB let me know. I do have Dropbox but have not used it
much. If you need the entire file, I can try to send in Dropbox. This is an extensive application and it may overcomplicate things if I send you
the entire file and the only issue I have, which is speed. But I'm more than happy to do that if it makes things easier.
I hope I've given you enough info to help. All I'd like to accomplish is get this to run faster. Please let me know if
you need more info

Once again, thanks for all yourhelp.
cr
 

Attachments

  • Screenshot 2023-09-14 Sheet2.  31103 rows.png
    Screenshot 2023-09-14 Sheet2. 31103 rows.png
    121.7 KB · Views: 9
  • Screenshot 2023-09-14 userform.png
    Screenshot 2023-09-14 userform.png
    102.6 KB · Views: 9
Upvote 0
It would be easier to test a possible solution if you could upload the file to DropBox and post the link to the file here. I wouldn't need the entire file, 40 or 50 rows of data (more if you wish) would probably be enough. The file should include the userform with any related code.
 
Upvote 0
It would be easier to test a possible solution if you could upload the file to DropBox and post the link to the file here. I wouldn't need the entire file, 40 or 50 rows of data (more if you wish) would probably be enough. The file should include the userform with any related code.
I don't know if I did this correctly, but if so, when you open the file you'll see this:
The code in the red button finds any value. If you back out John 1:42 and type the word east, it should give 628 occurrences
If it works for you, the button stays depressed too long. The underlying code and the sheet rows is where the slowdown occurs.
Feel free to navigate and explore this app. Nothing is confidential. It's a Bible application I've been developing for the last 2 years.
I just need to make it run better.

Please let me know if you run into any issues or have nay comments and/or questions.

Thanks again for taking the time to help with this.
cr
Kingwood, Tx
 

Attachments

  • OPENING VIEW.  LICK GREEN ICON.png
    OPENING VIEW. LICK GREEN ICON.png
    23.9 KB · Views: 8
  • MAIN WINDOW.  CLICK RED FIND BUTTON.png
    MAIN WINDOW. CLICK RED FIND BUTTON.png
    149.2 KB · Views: 8
  • TYPE east and press red button. Shoulf find 628 occurrences.png
    TYPE east and press red button. Shoulf find 628 occurrences.png
    149.7 KB · Views: 8
Upvote 0
@chazrab, what version of Excel are you using?
Hi mumps -
Got to this late. It's 4:30 AM CDT Fri 4/15/23 just chking this now.
Version info requested:
Microsoft® Excel® for Microsoft 365 MSO (Version 2308 Build 16.0.16731.20052) 64-bit
Saw your later email. Will chk it now.

KIT,
cr, thx again for help
 
Upvote 0
Hi mumps -
Got to this late. It's 4:30 AM CDT Fri 4/15/23 just chking this now.
Version info requested:
Microsoft® Excel® for Microsoft 365 MSO (Version 2308 Build 16.0.16731.20052) 64-bit
Saw your later email. Will chk it now.
Skyybot - sorry about that - I replied to this to fast. Same reply to your question, but addressing you directly:
Hi Skyybot
Got to this late. It's 4:30 AM CDT Fri 4/15/23 just chking this now.
Version info requested:
Microsoft® Excel® for Microsoft 365 MSO (Version 2308 Build 16.0.16731.20052) 64-bit
Saw your later email. Will chk it now.

Thx for helping also, Skyybot
cr
( I type way too fast and made several typos ) :)
 
Upvote 0
Hi mumps -
Got to this late. It's 4:30 AM CDT Fri 4/15/23 just chking this now.
Version info requested:
Microsoft® Excel® for Microsoft 365 MSO (Version 2308 Build 16.0.16731.20052) 64-bit
Saw your later email. Will chk it now.

KIT,
cr, thx again for help

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Done.
Thx Joe4

cr
 
Upvote 0

Forum statistics

Threads
1,215,165
Messages
6,123,390
Members
449,098
Latest member
ArturS75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top