Please Help me write this simple code

  • Thread starter Thread starter Legacy 185509
  • Start date Start date
L

Legacy 185509

Guest
Hi
I have this simple thing I want to put it into vba code so it will make my life easy

my vba code will search for this text "Resize to show all values" there will be around 100 or so search result. so if result is found do this apply this code if not found return

here are my code
here is search code

Code:
 Cells.Find(What:="resize to show all values", After:=ActiveCell, LookIn:= _
        xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext _
        , MatchCase:=False, SearchFormat:=False).Activate

and here is the code if that "resize to show all values" is found do this code
Code:
Call dlresize

please help me out
this will save me lots of time
Thank you
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
does this work?

Code:
Sub FindText()
Dim iLoop As Integer
Dim rNa As Range
Dim i As Integer

iLoop = WorksheetFunction.CountIf(Columns(1), "resize to show all values")
Set rNa = Range("A1")

 For i = 1 To iLoop
  Set rNa = Columns(1).Find(What:="resize to show all values", After:=rNa, _
             LookIn:=xlValues, LookAt:=xlWhole, _
             SearchOrder:=xlByRows, SearchDirection:=xlNext, _
             MatchCase:=True)
      Call dlresize
 Next i
MsgBox "Done"
End Sub
 
Upvote 0
Hey
It is not working if I try to run it just shows Msgbox Done
It should search for cell that contrains "resize to show all values" if that is found then it will call this code ---> "Call dlresize"
it is not doing that
by calling that code it will fetch the data from server, I don't want to manually click it, it is so much data thats why, may be if you can delay or something between loop will that help?
 
Last edited by a moderator:
Upvote 0
here is the picture of it

image removed, sensitive information

so I click the calculate on left side that code I am working on

this is the current code for it
Code:
Private Sub CommandButton1_Click()
Cells.Find(What:="resize to show all values", After:=ActiveCell, LookIn:= _
        xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext _
        , MatchCase:=False, SearchFormat:=False).Activate
Call dlresize
End Sub

If I click on it, it will search for "Resize to show all values" and after it find it will call this --> "Call dlresize" after that is called it will generate all the values like open close open close if you see I25 & K25 were done but I manually clicked Calculate for it to do that.(meaning one click on Caluclate will only do for one search) I want to make it like only click once and it will find that resize to show all values and will call dlresize for each and everyone of them.

ty plz let me know if this makes sense or not.
 
Last edited by a moderator:
Upvote 0
ok so when I tested with this it worked
Code:
Sub FindText()
Dim iLoop As Integer
Dim rNa As Range
Dim i As Integer

iLoop = WorksheetFunction.CountIf(Cells, "resize to show all values")
Set rNa = Range("A1")

 For i = 1 To iLoop
  Set rNa = Cells.Find(What:="resize to show all values", After:=rNa, _
             LookIn:=xlValues, LookAt:=xlWhole, _
             SearchOrder:=xlByRows, SearchDirection:=xlNext, _
             MatchCase:=False)
    If rNa Is Nothing Then GoTo 0
              rNa.Activate
      Call dlresize
0
 Next i
MsgBox "Done"
End Sub
Sub dlresize()
ActiveCell.Value = "FOUND IT"
End Sub
 
Upvote 0
Hey man thanx alot ur lifesaver
just wanna point one thing out
I took out this from bottom of code

Sub dlresize()
ActiveCell.Value = "FOUND IT"
End Sub

coz dlresize is built in method for the addon.

thanx alot again
I might need more help from you... tomorrow lol
 
Upvote 0
Hey got a quick question
need your advice
I have another button where I have to manually search each cell find it after that cell is found, some dialog box on right side will open up and I have to manually use mouse and click ok on it and repeat the steps for all the results plz suggest something ty


you can see the dialogbox in the picture above, "Sample Data" on right side of the screen in there I have to click apply or ok.
 
Upvote 0
Hey what if I want it to do same thing for sheet2, after Activesheet is complete
Thank you so much
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,550
Members
452,927
Latest member
rows and columns

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