Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Modify values

0

I have the next sequence:

searchValue = dashboard.Range("F6").Value

searchField = 9

It only searches in the 9th column of the excel. How can I modify it to search in all columns of the excel file? Need to search the first row, the headers.

And also, can you give me a Clear_data code that only clears columns 5, 9 and 12 please?

Answer
Discuss

Discussion

Squishy

Please revise your question to give the context to potential contributors (the question should be capable of reading without reference to your earlier questions). E.g. which tutorial or macro are you referring to? Also, do you want to clear the columns or leave the headers in place?
John_Ru (rep: 6142) Nov 24, '21 at 3:55 am
Fast Search Multiple Excel Workbooks using a File Picker Window - YouTube
this is the tutorial I am reffering. I modified it a little and I need that syntax 
searchValue = dashboard.Range("F6").Value searchField = 9
to not only search the 9th column, but all. It only return me the results if the name is on the 9th column. I want it to search every header of every column like a searchField from 1 to 30. 
I want to clear the columns, headers included. Like, when it returns me the columns from 1 to 20, to clear column 5, 9 and 12, and only leave me the rest
Squishy (rep: 18) Nov 24, '21 at 4:16 am
Also if I modify the searchField with a bigger number, say 21, it appears an error at

If (dataArray(i, searchField) = searchValue) Then
Squishy (rep: 18) Nov 24, '21 at 7:00 am
Squishy. that detail needs to be in the original question (not this Discussion)- if not, your chance of getting an anwer is reduced since contributors often don't have time to dig into conversations to find out what the question really is!

Also , on the macro, you say you have "modified it a little"- can you uplaod your file into your original question please? If possible, also add a represemtive file to search through.

 
John_Ru (rep: 6142) Nov 24, '21 at 7:10 am
I managed to solve it. Thanks
Squishy (rep: 18) Nov 25, '21 at 3:14 am
That's good to hear!
John_Ru (rep: 6142) Nov 25, '21 at 3:55 am
Add to Discussion



Answer the Question

You must create an account to use the forum. Create an Account or Login