473,385 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need help with my search macro for excel

21
I recently received help writing a search macro for excel, but now I am trying to change it up to use it in another spreadsheet, and I am having some troubles. I need it to search two cells one has a month (cell B4) and the other has a year(cell B5). The macro that I have works great for searching just the month, but I don't know how to change it to incorporate another cell with the year in it. I really appreciate the help this forum provides.
Below is the macro I am currently using.

Expand|Select|Wrap|Line Numbers
  1. Sub TextBox11_Click()
  2.      Dim searchNum As String
  3.  
  4.     searchNum = InputBox("Enter Month Year")
  5.     If searchNum = "" Then Exit Sub
  6.     Sheets("Archive").Select
  7.     Range("B99").Value = searchNum
  8.     Range("B100").Activate
  9.     For i = 1 To 120
  10.             ActiveCell.Value = "=vlookup(B99,B4:DQ53," & i & ",FALSE)"
  11.         ActiveCell.Offset(rowOffset:=0, columnOffset:=1).Activate
  12.     Next i
  13.  
  14.     Range("A1").Select
  15.     Sheets("Searched Report").Select
  16.     Range("A1").Select
  17.  
  18. End Sub
Aug 26 '08 #1
2 1909
jotr
21
Sorry I made a mistake the month is in column B starting in row 4 and the year is in column C starting in row 4! I also would like for there to be two separate text boxes for the month and year, which I know how to do that but I don't know how to combine the two columns into the search results. The same row will always have the month and year I am searching for if that helps at all. I have changed my code to incorporate the two text boxes to enter my search in, so I am going to relist it.

Expand|Select|Wrap|Line Numbers
  1. Sub TextBoxSearch_Click()
  2.      Dim searchNum As String
  3.      Dim intRng As Integer
  4.  
  5.     searchNum = InputBox("Enter Month")
  6.     If searchNum = "" Then Exit Sub
  7.     intRng = InputBox("Enter Year")
  8.     Sheets("Archive").Select
  9.     ActiveSheet.Unprotect
  10.     Range("B99").Value = searchNum
  11.     Range("C99").Value = intRng
  12.     Range("B100").Activate
  13.     For i = 1 To 120
  14.             ActiveCell.Value = "=vlookup(B99,B4:DQ53," & i & ",FALSE)"
  15.         ActiveCell.Offset(rowOffset:=0, columnOffset:=1).Activate
  16.     Next i
  17.  
  18.     Range("A1").Select
  19.     ActiveSheet.Protect
  20.     Sheets("Searched Report").Select
  21.     Range("A1").Select
  22.  
  23. End Sub
Thanks again
Aug 28 '08 #2
NeoPa
32,556 Expert Mod 16PB
This question was asked incorrectly, so the OP reposted as Excel VBA: Search Problems.
Sep 6 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Marc | last post by:
Hi all, I am trying to write an application where I need the ability to open an Excel spreadsheet and do basic read/write, insert rows, and hide/unhide rows. Using win32com I have been able to...
0
by: Alex | last post by:
i have a module in Access which opens an existing Excel file and envokes a macro within the Excel file to draw graphs. now i am trying to convert the Excel macro to an Access one so that the...
1
by: Giganews | last post by:
I have an Access 97 database in which I am running an Excel macro through automation. The macro in Excel is as follows: Worksheets("Sheet1").Protect Password:="****", DrawingObjects:=True,...
4
by: Rich Wallace | last post by:
Is there a way to open an Excel file and either respond to or supress the Macro warning window via VB.NET? Dim oExcel As Excel.Workbook Dim sFilePath As String = "C:\DailyReport.xls" oExcel...
2
by: cr113 | last post by:
I just upgraded from Office 2000 to Office 2003. My VB.NET Excel macro calls don't work any longer. Here is how I make my Excel macro call from VB.NET: Dim objExcel as Excel.Application ...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
1
by: eskelies | last post by:
Below you will find the code that I have written. I am asking it to search for an Excel file. Once it finds the correct dated Excel file it opens it. From there it is in search of information. I...
3
by: ManuelValdez | last post by:
Hello everybody! I need your valuable help to get an Excel macro to delete the single zeros only and no the zeros containing numbers like 360, 90, etc., because if I chose the search and replace...
0
by: arunbalait | last post by:
Hi Sorry I dont know where to post this question. Apologize if this is a wrong section I need a macro for finding duplicate entries in Excel. There are lost of Duplicate entries in various...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.