Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a spreadsheet that is filled with data quarterly.
I think I want to have the macro look for Q1, which would be via an input box, find Q1 and begin entering the data from that point on. Any suggestions? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
You don't mean you have allocated some rows for q1,q2,q3,q4 ,do you? What is the display of your sheet ? Pls give us some more details. Otherwise you can always use excel built in "find" which is the fastest method. rgds |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mar 19, 1:01 pm, Clarissa
wrote: I have a spreadsheet that is filled with data quarterly. I think I want to have the macro look for Q1, which would be via an input box, find Q1 and begin entering the data from that point on. Any suggestions? Clarissa, You can do something similar to the following: Option Explicit Sub findQ1() Dim response response = InputBox("Input the corresponding quarter","Q?","Q1") 'note: you'll probably want to validate that the input text is ''Q1, Q2, Q3, or Q4. Cells.Find(What:=response).Activate 'Find has a lot more parameters than just "What" 'then once the cell is found you can output the values by using something 'like ActiveCell.Offset(row,col).Value = ..... End Sub As a side note, look up the "Find" and "Search" functions in the Excel help. Matt |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Matt,
This was helpful. As I said the report is run quarterly, i.e. March, June, September and December. The report has 23 spreadsheets for each division, so the "response" will work magnificently until the macro gets too large and then I'll have to call another macro to run similarly for the remainder of the divisions, the user will then have to input the current quarter again. Is there a way, for example, that I can add an IF - like if current month = "March" look for Q1 and so forth? Thank you "matt" wrote: On Mar 19, 1:01 pm, Clarissa wrote: I have a spreadsheet that is filled with data quarterly. I think I want to have the macro look for Q1, which would be via an input box, find Q1 and begin entering the data from that point on. Any suggestions? Clarissa, You can do something similar to the following: Option Explicit Sub findQ1() Dim response response = InputBox("Input the corresponding quarter","Q?","Q1") 'note: you'll probably want to validate that the input text is ''Q1, Q2, Q3, or Q4. Cells.Find(What:=response).Activate 'Find has a lot more parameters than just "What" 'then once the cell is found you can output the values by using something 'like ActiveCell.Offset(row,col).Value = ..... End Sub As a side note, look up the "Find" and "Search" functions in the Excel help. Matt |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mar 20, 12:00 pm, Clarissa
wrote: Thanks Matt, This was helpful. As I said the report is run quarterly, i.e. March, June, September and December. The report has 23 spreadsheets for each division, so the "response" will work magnificently until the macro gets too large and then I'll have to call another macro to run similarly for the remainder of the divisions, the user will then have to input the current quarter again. Is there a way, for example, that I can add an IF - like if current month = "March" look for Q1 and so forth? Thank you "matt" wrote: On Mar 19, 1:01 pm, Clarissa wrote: I have a spreadsheet that is filled with data quarterly. I think I want to have the macro look for Q1, which would be via an input box, find Q1 and begin entering the data from that point on. Any suggestions? Clarissa, You can do something similar to the following: Option Explicit Sub findQ1() Dim response response = InputBox("Input the corresponding quarter","Q?","Q1") 'note: you'll probably want to validate that the input text is ''Q1, Q2, Q3, or Q4. Cells.Find(What:=response).Activate 'Find has a lot more parameters than just "What" 'then once the cell is found you can output the values by using something 'like ActiveCell.Offset(row,col).Value = ..... End Sub As a side note, look up the "Find" and "Search" functions in the Excel help. Matt- Hide quoted text - - Show quoted text - Clarissa, In the VBE Help section, search "Select Case Statement" and "If...Then...Else Statement," and you should find what you need. In short, if you pull the current month in (whether from the ActiveCell or from an InputBox), you can run the value through a Case Statement to output what you want. The following should help lead you in the right direction. By the way, I'm not sure what you mean by "...until the macro gets too large..." (Don't discount the ability of Excel). If the quarter END is Mar, Jun, Sep, and Dec (i.e. the fiscal year end is Dec). Option Explicit Sub findQuarters() Dim response Dim findTxt Dim monthDate monthDate = Format(DateSerial(Year(Date), Month(Date), Day(Date)), "mmmm") response = InputBox("Input the current month","Current Month",monthDate) 'note: you'll probably want to validate that the input text is valid Select Case response Case "January" findTxt = "Q1" Case "February" findTxt = "Q1" Case "March" findTxt = "Q1" Case "April" findTxt = "Q2" Case "May" findTxt = "Q2" Case "June" findTxt = "Q2" Case "July" findTxt = "Q3" Case "August" findTxt = "Q3" Case "September" findTxt = "Q3" Case "October" findTxt = "Q4" Case "November" findTxt = "Q4" Case "December" findTxt = "Q4" End Select Cells.Find(What:=findTxt).Activate 'Find has a lot more parameters than just "What" ''Also, keep in mind that you need to code something that ''will work if "findTxt" is Nothing. 'then once the cell is found you can output the values by using something 'like ActiveCell.Offset(row,col).Value = ..... End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find & Replace: find part cell, replace whole cell | Excel Worksheet Functions | |||
find first empty cell in column and start transpose next row in that cell | Excel Discussion (Misc queries) | |||
Find First Non blank cell than find column header and return that value | Excel Worksheet Functions | |||
UDF code to find specific text in cell comments, then average cell values | Excel Programming | |||
use find twice to find cell on a specific row | Excel Programming |