Putting Input Into A Macro

Apr 24, 2007

I would like to write a macro that would start by asking me something along the lines of, "Enter student # you want to print a report about." The # I enter would need to be stored as a variable in the VB code, and then my code would need to use the variable to do some search and replace operations. (Replace all instances of 10 (the default student number) with the variable I have specified).

I don't really know how to even start going about this. How do I get Excel to ask me for a variable, and then use that variable in code?

View 9 Replies


ADVERTISEMENT

Putting Input Box Into Existing Code

Jan 22, 2009

On the "If not Isempty" line, I am trying to input a box prompt. Instead of standardizing this macro, I want the user to be able to select a dollar amount to search and place on sheet3. Right now it works fine using 1.29 as the amount. However, I have other stores where this dollar amount is different, so I want the store managers to be able to choose an amount to search, for example 1.39, 2.99 etc...

View 2 Replies View Related

Macro Putting In The Formula As Text Instead Of Results

May 28, 2008

My macro contains a VLookup formula that is giving me the text of the formula instead of the results. A portion of the macro is, as follows:

Sheets("Survey Results").Select
Range("c1").Value = "Resolving Group"
Range("c2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],'Survey Invitation'!C[-2]:C[-1],2,FALSE)"
Range("C2").Select
Selection.AutoFill Destination:=Range("C2:C900"), Type:=xlFillDefault
Range("C2:C900").Select
Range("C2").Select

The VLookup statement appears in place of the result when the macro is run. This is Excel 2007 and it runs to the end without error.

View 9 Replies View Related

Macro For Putting Index Reference Numbers In Numerical Sequence?

Nov 12, 2012

I have a document that is a subject index for book that has terms that reference page numbers. The structure is for example: Employment, 587, 592, 553, 605, 233 The term is always following by comma and then space and listing of page numbers that subject reference applies. In many cases the page number references are out of sequence and I need them to be in numerical sequence. i.e. Employment, 233, 553, 587, 592, 605 There are many subject terms in index and need to check and fix sequence of page references for each.

View 6 Replies View Related

Putting The "right" Command In A Macro

Feb 2, 2007

I am trying to add a formula to use the "Right" command in a macro, but I dont want it to remove any characters on certain cells. For instance i want to remove the seventh digit from the right only if it is a Zero. If it is any other number, i want it to skip that cell.

00234XX
021V54Q
1405RS1
5843TP1

So i would only want it to remove the zero from the top two and leave the last two as they are. The ammount of information changes on a daily basis so the formula would have to be able to distinguish the values of the first digit.

View 3 Replies View Related

User Inputs Area Into Macro And Macro Continues To Run After Input

Oct 9, 2012

I have recorded the following marco and it works fine. I would like to modify it so the user would highlight a range of cells rather than have the fixed area :

"'ConsExecProp@20120920'!R4C5:R113C21"

What code lines would need to be added?

Application.Goto Reference:="R4C5"
ActiveWorkbook.PivotCaches.Create(SourceType:=xlConsolidation, SourceData:= _
Array("'ConsExecProp@20120920'!R4C5:R113C21"), Version:=xlPivotTableVersion12 _

[code]....

View 4 Replies View Related

Using An Input Value In A Macro

Jan 14, 2009

I have an excel file with several rows of data in it, and have a macro currently written to fill out a blank form from the information in a given row. I was wondering if there is a way to prompt the user to input which row you want the data to be pulled from.

For example:

Which row to input data from?
- 4

Then have the macro run, pulling the data from the cells in row 4, rather than row 2, which is how I have written it to begin with.

I didnt write the code from scratch, I just used the record function and it traced my actions, and does what I want it to do, but only for the data in row 2...and I want to be able to specify which row to pull data from.

View 9 Replies View Related

VBA Macro Using Calculated Value Out As New Input In

Jul 21, 2012

I am trying to write a VBA macro that will mimic what i have already done in an excel worksheet i have made. The excel worksheet uses inputs for a heat exchanger and finds the temperature as it leaves the heat exchanger. This temperature is then the new input for the second line of the worksheet and it changes quite a few of the values in the sheet. I have the excel worksheet working where you just drage the row down and it does it automaticly, but i would like to have a VBA macro that all the values can be input in with the number of cycles until the heat exchanger equalizes out.

I am able to get the macro to work when it calculates just the first cycle, all the equations work my variables are ok for just one time. What i don't know how to do is make my program realize that it has to use the calculated temperature out of the heat exchanger as my new input for the heat exchanger. I know how to do it once so it is more of a syntax or understanding of a loop or an array for the values that are changing.

View 4 Replies View Related

Sort Macro And Input Box

May 10, 2007

With guidance from this board in the past, I was directed to a macro that sorted information on a sheet (using values in column 1), opening a new sheet named by the sort title then copy/pasting all the relevant entries

The only restriction for this macro is the fact it is set to only sort information on sheet named Sheet1

I wanted to change this to an InputBox so the user can tell the macro which sheet to sort

View 9 Replies View Related

Macro To Input A Formula

Mar 26, 2009

i need a macro to insert the formula i have in Column M row 3, and insert it all the way down to the last letter that is contained in column k. So in this example The Last Letter in Column K is AQ, ( i dont physically mean last i mean last in alphabetical order in excel , such as ( W X Y Z, AB, AC , AD ) AD would be last.

So since AQ is last it would insert the formula 43 times, which is AQ. THe AFter tab should clear any confusion up because this is how it looks finished. I use various sheets like this so the last letter changes, so having this macro be dynamic and not attached to a sheet name would be ideal.

View 2 Replies View Related

Macro User Input

Mar 28, 2009

I would like to do a Macro which requires user to go to a specific line which is variable in each work sheet. I would like to be able to enter the number and then delete all lines below that point and then continue with the balance of the macro.

Is there an easy way to pause the Macro and then restart it? Or is there a code that I can insert in the Macro to locate a specific Cell and then delete all lines below the next line?

View 4 Replies View Related

Input Data Macro

Apr 18, 2009

I am looking for a macro which will help make my workbook more user friendly.

Is it possible to have a macro which when run brings up dialog boxes for user input into certain sheets etc.?

View 14 Replies View Related

Search And Input Macro

Nov 2, 2009

I have a document with multiple sheets that contain data for a specific date and are set up in chronological order. The last sheet(Final Sheet) has each row as a different date in a chronological range of 3 yrs and each row has 5 cells of data.

I need to write a macro that will take a 5 cell row from each sheet and place it in the correlating date/row in the Final Sheet. Each sheet is labeled as the date for which the data is from so the macro needs to match the sheet title to the date in column A of Final Sheet. Then place the 5 cells from the sheet into the correlating date/row. The macro would need to loop through and do this until it reaches the Final Sheet.

View 9 Replies View Related

Removing Input Box From Macro?

Feb 10, 2012

However, with this macro I am wanting to remove the Input Box that pops up and requires the user to hit 'enter' everytime the macro runs. Instead, I would like the macro to automatically insert the rows based upon the value of cell A1 without having to confirm with the Input Box.

Code:
Sub InsertRowsAndFillFormulas_caller()
Call InsertRowsAndFillFormulas
End Sub

[Code]....

Because I am such a novice with coding, if the response could be in a form where the entire macro code is spelled out on what needs to be changed. That way I can just copy and paste the macro response instead of having to try and figure out how to apply your suggestions to my existing code.

View 9 Replies View Related

Macro To Save As With Input

Jan 30, 2007

Macro to save as "xxx" Input box "___".xls
in the same folder as the original file?


xxx is defalut part of file name and input box for user to add criteria about file.xls

ie.. xxx_critera.xls

View 9 Replies View Related

Input Box Next To A Macro Button

Nov 24, 2009

I have this macro in which the user clicks a button and it formats a file for them. I want a box next to the button where the user can enter a number first then click the button and then the file will use that number to calculate a column. Any help is appreciated.

For example part of my macro is this.

Lcol = Range("IV5").End(xlToLeft).Column + 1
Cells(5, Lcol) = "Total Cost"
Worksheets("sheet1").Range("u6").Formula = "=IFERROR((RC[-1]/RC[-3])*the number the person entered first,0)"
Lrow = Range("A" & Rows.Count).End(xlUp).row
Range("u6").AutoFill Destination:=Range("u6:u" & Lrow), Type:=xlFillDefault
With Range("u6:u" & Lrow)
.Copy
.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End With
Application.CutCopyMode = False

View 9 Replies View Related

Repeat Macro From User Input

Jun 14, 2008

I have a very simple macro for recalculating formulas and printing the page.

I need a way to show an input box where the user can say how many times to repeat the process i.e. 2x = recalculate, print, recalculate, print.

View 11 Replies View Related

Getting User Input For Find Macro

Feb 27, 2009

Due to the economy we are only scheduling days to work one week ahead which leads to alot of phone calls. The gaurds who get the calls then search thru a printed spreadsheet looking for a clock number or last name. I realized right away they should just look at the file on the computer and due edit - find. The problem is they due not use computers unless printing and they looked at me like I was talking in a different language. So I want to edit this macro below so it will allow user to type in search criteria instead of using same search criteria every time. Here it is 70039. I also need to place a shortcut or button to this macro on the toolbar or sheet and do not know how. How do I stop "remove macro or enable when file is loaded"?

View 3 Replies View Related

Run Macro After Cell Data Input

Jan 24, 2012

I want to run a macro that unhides 15 lines (line 20 to 35) when data is inputed on cell 'F6' and to run another macro called "search" (i have already finished this macro) which will fill in information on the unhidden lines from above.

View 4 Replies View Related

Macro To Enter Data Without Using Input Box

Aug 25, 2012

I need a simple macro to enter data for hours worked, but don't like the inputbox.

I need to enter the Emp Nbr in B1.
AM in Time in B3
AM out Time in B4
PM in Time in B7
PM out Time in B8

I then write down the hours worked and

Return to B1

When I enter an new number, I want it to put 0 in B3,B4,B7 and B8

(see attached) Oops can't post. There is probably a better way to calculate the sub-totals, but this works except on an enter of 1200

View 5 Replies View Related

Loop Macro. Prompt Input.

Sep 4, 2009

I have several hundred workbooks with multiple worksheets(15-35) that I am trying to tidy up, so the data can be entered into a database. Its my first attempt at VBA and between the forum and macro recorder I made an attempt which is below. I just can't seem to get over the last part. I have searched the forum but can't seem to find any relevant information. I have a couple of questions.

1. I need to be able to run this macro over all the worksheets in the workbook, so how can I loop it? All the worksheets are named differently i.e. peoples names.

2. In my code I have inserted 4 columns. These columns will be the only thing common between all the worksheets. A1 to A30 = Week number, B1 to B30 = Shift Number, C1 to C30 = Supervisor number. Column D is blank. I'd like to be able to be prompted to enter these 3 numbers at the start if possible? Can this be done in such a way as you are only prompted the once and not on each worksheet? I picked 30 rows because the amount of rows in each worksheet varies but never exceeds this. The end of my code "Delete rows where cell B is blank" will delete any excess data where 30 rows of week numbers etc are not needed.

Sub CleanCost1_1()
'
' CleanCost1_1 Macro
' Macro recorded 04/09/2009
'

' Delete Job Card Sheet
Sheets("Job Card").Select
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
' Delete Master Sheet

View 9 Replies View Related

Run A Macro Based On Value Input In A Cell

Jul 19, 2006

I am using data validation to restrict the number of Characters a user can input in a range of cells. The number of characters in this however can vary based on which selection they selected in a different cell.

To put this as an example, if the user selects "hello" in cell a1, the data validation would allow 10 letters in the cell range c1:c20. If the person selects "goodbye" in cell a1, then the validation would only allow 7 characters in cell range c1:c20. I have been using the worksheet Change function, however it updates the validation regardless of what cell is changed.

View 7 Replies View Related

Putting A Space

Nov 12, 2008

how do I put a space?

12345 ** =A1&B2 gives me 12345CD

but I want 12345 **

View 2 Replies View Related

Putting Two Cells Together With 0

Mar 26, 2014

I have a cell in A1=(str identification is = ",) and in B1=(2). In C1 I want it to equal (str identification is = ",02) In C1 I have A1&B1

View 4 Replies View Related

Putting Another Code In The Same Sub

Jul 1, 2008

putting another code in the same sub.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Set rng = Range("O2:O501")

If Intersect(Target, rng) Is Nothing Then Exit Sub

If Target.Value "X" Then
With Target
.Value = "X"
With .Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 14
.ColorIndex = 3
End With

Plus this one

Set rng = Range("P2:P501")

If Intersect(Target, rng) Is Nothing Then Exit Sub

If Target.Value "X" Then
With Target
.Value = "X"
With .Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 14
.ColorIndex = 5
End With

View 9 Replies View Related

Changing Input And Range From Current Macro?

Apr 10, 2013

So I found a macro that does something similar to what I need.

I tried changing the data range and input column but it doesn't work.

What the macro does is I type whatever name into the msg box and it will copy and paste all the rows that contains the name to a different sheet.

Here is the macro:

VB:
Sub test()Dim vl As String, res, sh, myrange As Range
Application.ScreenUpdating = False: vl = Application.InputBox("Enter value for Column B", Type:=2): If vl = "" Then Exit Sub

[Code]....

View 5 Replies View Related

Using Data From Input Box In Array Formula In Macro

Nov 10, 2011

I often have to research long sheets of data, which requires filling data in on my research sheet from several different sources. The research sheet has a file # in A and a vendor # in C. The data sources have the file #s & vendor #s in varying columns, but I use a pivot table to end up with file # in A, vendor # in B and the needed data in C.

The length of the research sheet varies from month to month - often 800-900 rows, so you can imagine how tedious it is to find the correct file #/vendor # combination to plug the data in. (Many of the rows on the research sheet will not have a row on the data source sheet.)

I managed to get an array formula in one of the columns on the research sheet that actually DOES work:

Code:

{=INDEX('Acct Activity'!C$1:C$7,MATCH(A7&C7,'Acct Activity'!A$1:A$7&'Acct Activity'!B$1:B$7,0))}

But the problem is that it returns #N/A in any row that doesn't have any data. This messes up the sum formula in the farthest right column. So, I tried to incorporate an ISERROR in with the formula, but couldn't get it to work; it left all the cells blank.

In the meantime, I got to thinking that, since there are up to 3 columns requiring data on the research sheet & each column's data comes from a different source, wouldn't it be great to have a macro where I could use a couple of Input Boxes: 1 that would let me click on the column where the data NEEDS to go & 1 that would let me tell it (either by typing the worksheet name or by clicking on the worksheet " PREFERRED " where the data come from)!

So, I spent the entire day yesterday trying to make any of that work & can NOT figure it out! I got the macro to pop up the first input box, & can key in the column letter, but clicking OK doesn't do anything. Yesterday, I had it so I could click OK & the box would go away, but nothing else happened & the second box wouldn't work right.

THEN, I started trying to figure out how to do an array formula in a macro & my head nearly exploded! I have a terrible time trying to understand written descriptions if they're in "tech speak", so it was all greek to me.

Here is all the farther I got with the macro:

Code:

Sub ClearingRsch()
' Jenny 10092011
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
.DisplayAlerts = False

[Code] ......

View 9 Replies View Related

Highlighting Changes In Cell After Data Input Macro Run

Jun 27, 2013

I work for a marketing agency where technical savvy-ness is really limited. We analyze a lot of web page elements. I have a program that exports this data into a csv file and I've created a template for the user to add this sheet. This data is primarily text. I've created a button on another sheet that runs a macro that extracts data from the first sheet onto the second sheet in a particular format for ease of reading and editing it. That part is all good, this macro works and the button works. Now I'm trying to have it such when a person edits one of these cells, it highlights the changes on this newly sheet using VBA (the highlighting changes function just turned out to be too messy and buggy for what I want). I have this basic change macro that I have on the sheet currently:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H500"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Interior.ColorIndex = 30
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

This works as well. However, my problem is that when I run the data button macro, of course excel reads this as a change to the cell and highlights it as a change before any actual changes are made. How can I have it so I run my data macro, and the cell changes are highlighted only *after* the user goes in to edit the text data plugged in from the data macro?

View 3 Replies View Related

Macro For Input Box To Replace Formula Cells With 0?

Jul 22, 2014

Sample Data from "Demand Planning Prem" worksheet

Date
SKU
Name
Begin FG's

[Code]....

This worksheet has around 40,000 records, and I need to create a Macro that will ask the user for a date, and when the user enters a date the macro goes through column A and finds all of the matching dates and then replaces the numbers (along with the formulas) in the corresponding Add Returns cells (column E) with 0's.

I have only been able to create an inputbox, but I am completely lost regarding the criteria due to being very new to VBA.

Sub ClearData()
Dim EnterDate As Date
Dim msg As String

[Code].....

View 2 Replies View Related

Reference To A Range Of Cells As Input For A Macro

May 13, 2009

I want to create a macro which asks some information like functions do. For example, I would like the macro to ask for some data to be filled by the user. For that purpose I thought about using the inputBox vba function. I wanna fill the field in the inputBox with a reference to a range from an excel sheet. So, I click on a cell and then I try to hold ctrl + down cursor to get all the range starting from that cell on until the last consecutive filled cell on the sheet. Nonetheless, the problem I have is that when I do ctrl+down cursor, I just do not get the reference I want, because it seems that the ctrl+down cursor combination does not work in the inputbox for filling a reference to a range of cells. Does anyone know some workaround to achieve this?

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved