I have an existing macro which I am enhancing and I would like to have the user provide a date, either with a popup text box in a userform and then use a command button to hit OK and have the box dissapear, or in a calender which the date is selectable, and the date supplied go into a variable.
want to do something simple, and it just wont paste. not sure why. anyone care to look it over and tell me what i'm doing wrong here?
'Insert Date Information Dim vDate As Date Range("D2").Select ActiveCell.FormulaR1C1 = Date vDate = Date
'Get date from user Dim dDate As Date vDate2 = Application.InputBox(Prompt:="Type in the due date for the location." _ & Chr(13) & Chr(13) & "*If you want the date to default to " & Date + 5 & " then leave the field blank.", _ Title:="Due Date", Type:=1 + 2).............
We have an excel file which is made every thursday for comparison purposes etc. I've made an macro (excel 2003) which - on start - asks via an inputbox for the extension in date format for saving purposes. Later on, the macro will search for the same file but from last week to open it and copy/paste a 'comments' column into this new one. All went well, everybody happy. However it may be well possible that file is made and saved but with an extra extension: example:
dir to save = C:file
file when starts runs inputbox "Please enter a date (e.g. 2008-06-20)" The macro records this string as mydate:
Sub Start() Dim AnyString Dim MyStr Dim DirString Dim mynum 'As String Dim resp As Long Dim get_mynum Dim mydate
'Define extension for the file name to be saved and the correct path (dir) where this file will be stored. get_mynum: mynum = Application.InputBox("Enter the filename's extension to save in yyyy-mm-dd (e.g. 2008-06-30)", vbOKCancel) If mynum = False Then msgbox ("You do not want to continue? Ok, programm stopped") Exit Sub ElseIf mynum = "" Then..............
I am using this program in one workbook to capture the datevalue in integer from another workbook which i opened. But the program as it reaches the line x2=Datevalue( Cells(2,14).Value) gives a Type Mismatch error.
Public Sub find_date() Dim x2 As Long
'I am trying to activate the last opened file by using workbooks.count Workbooks(Workbooks.Count).Activate Worksheets("Sheet1").Cells(1, 1).Select
x2 = DateValue(Cells(2, 14).Value)
Auto Merged Post Until 24 Hrs Passes;btw..the cells(2,14) has a date, formatted in the type of mm/dd/yyyy.
The above Date si used in a sql select statement where I'm hard coding the date (9/20/2007). This date is actually located in sheet1, cell E1. How can I get it from that cell and use it in my Select statement instead of entering the date manually every day in my code?
How do I use VBA to send the value of a cell, for example, cell J77 to the variable "mastervalue1"?
I have a spreadsheet that has a column with dates ( in the format "mmm-yy") and next to it a column that has values. I want to pass the value of the cell that is next to the date cell that contains today's month to a variable in VBA. Auto Merged Post;here's an example of my spreadsheet
I have a workbook that is used to track overtime hours worked through the year. I've received some help from users on this forum, and others, to create the necessary macros and formulas to allow a supervisor to make use of the form; however, the workbook is also used to track those that wish to volunteer to work overtime each weekend. The sheet has a list of names for the employees on each shift, then a column to allow a "Y" to be placed under the date - designating them as a volunteer for any overtime available. I've found this spreadsheet (attached - from this site) that will allow individual users to access the workbook and have unique passwords for each. I don't completely understand how it works, but I feel it may be a start to getting what I want.
Essentially, once the user selects their name and inputs their password, I'd like the workbook to be opened and then allow them to only manipulate the row associated with their name. That row will change from week to week, so specific numbers will not be able to be used, but their name will be the same as the name used in the logon.
I feel like I'm asking for a lot here, so just some initial guidance on whether this type of thing is possible would be an acceptable answer.
Date = InputBox("Enter the production month date in YYYYMM format", "DATE") 'This is the only info I want them to enter
Windows("PCN4.xls").Activate Sheets("Bring the data in here").Select Range("A" & NextLine).Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;W:C30MonthlyMonthly NEW TCs200610 otconsa.txt", Destination:=Range _ ' I only need the 200610 to change every month ("A" & NextLine)) .Name = "totconsa" End With
I create a macro which ask the user to input a formula(user can select a range in the excel screen), then I copy this formula to a specific row of every worksheets.
The problem is Application.InputBox("Insert a Formula", "This accepts Formula", 0+2) can not return the formula, it will automatically evaluate this formula and return a value!
This code is:
Sub CreateNewItem1() Dim bFormula As String hi=10 Application. ScreenUpdating = True
' here is the INPUTBOX-method : On Error Resume Next Application.DisplayAlerts = False bFormula =Application.InputBox("Insert a Formula", "This accepts Formula", 0+2 ) On Error Goto 0 Application.DisplayAlerts = True MsgBox "You have inserted bFormula is:" & bFormula
I have an input box for a password, and my vb code checks the password against a list, and if it is correct allows the user to continue. I want to change the input box for a user form, as it allows more text on the form, and I also want to include a checkbox that the user must tick to show that they have read and understood the instructions. I have defined the form, but am having trouble getting the form to interpret the user input.
The form has one checkbox, which needs to be ticked to continue, otherwise give a message saying that you have to confirm. It also has one textbox, for the user to input the password. I dont understand how to name the contents of the text box, and use it in the following code. Also do I need a "send" button on the user form, for the user to click after entering the password. If so how does that work?
I want to select a cell that contains a job number, use the text from that cell as the new file save as name (got the file creation part sorted out) and then continue from there to go back and create a hyperlink in the original cell to the newly generated spreadsheet. I know it involves variables, have tried things like currentcell.value but can't get what I want.
The first goes through a directory and opens all the files.. after it opens a given file it goes off into a sub-routine to process the data in that file.
I am trying to create a counter in the first sub-routine and then pass that value into the second sub-routine to tell it to put the values out on the next row down.. so the first time through it puts the values out on row 1, next time it puts them out on row 2, etc.
I'm working on a spreadhseet which has several macros that can take up to 5 minutes to run. When the macro(s) complete, I pop up a userform to provide instructions and collect some additional data from the user.
The "problem" is that when the user moves to another application to do other work, the user form remains hidden behind the active app. I've added some text to the status bar to let the users know the processing is done, but they would like something more obvious - so, is there any way I can force focus back to Excel?
I have created a custome User Form with three option buttons inside a frame. How do I set the value for each button and then how do I pass that value back to the code that opened the form (after closing the form upon a selection?
Sub Test2() UserForm1.Show Select Case List Case 1 Range("b1").Value = "List 1" Case 2 Range("B1").Value = "List 2" Case 3 Range("B1").Value = "List 3" End Select End Sub
in the form I have the following code associated with each of the butons (but I do not think I have it right). Isn't there a way (becasue I have them in a frame) to shorten the code?.................
I am trying to write a User Defined Function in VBA to perform a simple two-dimensional table lookup. I have the temperature distribution in a solid given in a table in Sheet2. The first column of the table contains the time values, the first row contains the spacial values (radii), and the intersections contain temperature values. These ranges are named times, radii, and temperatures. In Excel, I can perform the lookup using: =index(temperatures, match(time, times, 1), match(radius, radii, 1))
But how do you do this in VBA? More specifically, how do you deal with passing ranges to the WorksheetFunctions?
Function temperature_ref(time_range As Range, radii_range As Range, temperatures_range As Range, time As Double, raduis As Double)
r = WorksheetFunction.Match(time, time_range, 1) c = WorksheetFunction.Match(radius, radii_range, 1) temperature = WorksheetFunction.Index(temperatures_range, r, c) End Function
This function would be called (from any worksheet) as..................
I have an array with structure, i.e. User Defined Type. Assume the user defined type has two elements: Element1 and Element2 and array name is Array.
So the definition is:
Dim Array(1 To 10) As UserType
and access to elements is
The problem is that I need to pass the whole set of Element1 or Element2 to a function. Should it have been two separate arrays, it would not be a problem. But because of the user defined structure I have no idea how to pass a single element.
I hope there is another solution rather than to use loops. I have many arrays like this with complex structures. I simply can not replicate all of them.
I am calling a sub that I want to do a SaveCopyAs using a variable as the file name but can't get it to work. The file name displays properly in a message box but when I do a SaveCopyAs it does nothing.
I have code in a userform that shows another userform with a text box. When the user types text there and presses OK, I want that userform to close (which it does fine), and return back to the original userform (which it does fine), but I want the typed text to be stored in a variable that the code in the original userform can use.
I tried declaring a public variable, "Rresponse1", in each userform's procedure, but that doesn't work. I test for the content of the variable afterward in the original userform and it is empty.
In the original userform I have:
SaveList.Show '(this is the second userform) MsgBox "This is response1: " & Response1 '(to test if the variable is being passed)
In the userform SaveList, in the Private Sub CommandButton1_Click() procedure, I have:
Response1 = SaveList.ListName.Text Application.ScreenUpdating = True MsgBox Response1 '(to test the variable, here it shows the text fine) Unload SaveList
How do I get the Response1 variable to keep its content when control is passed back to the original userform?
I am trying to call a function that calculates forecast error (wMAPE). This function needs to be able to handle passing in non-contiguous ranges. I can't seem to figure out how to do that.
Function wMAPE(Forecasts As Range, Actuals As Range, Weights As Range) As Variant Dim Denominator As Double Dim Numerator As Double Dim i As Long Dim Fcst As Variant Dim Act As Variant Dim Wt As Variant
If Forecasts.Cells.Count Actuals.Cells.Count Then MsgBox ("Error: Arrays not same size") If Forecasts.Cells.Count Weights.Cells.Count Then MsgBox ("Error: Arrays not same size")
I am trying to pass two variables RARD and CARD from Sheet1 'change selection' subroutine to the 'Set ARD Command button click' subroutine. The variable value remain empty and it gives me a 1004 error when I try to execute this line of code:
What I am trying to do is put the text value 'ARD' in the cell on sheet1 which was the original cell I clicked on to open the userform2. To do this I click on the 'Set ARD' button on the userform2 which is then suppose to hide the userform2 and put the 'ARD' text in the selected cell on Sheet1.
I have attached the workbook for review : Therapy Tracker - Tester V2.10 - deleted logo.xlsm
I have a spreadsheet with about 30 charts on it that I would like to attach a macro to which opens the chart in a form. I've figured out how to do this last part, but am stuck on how to pass a variable to the form code which tells excel which chart to copy. Essentially what I'm doing creating a macro for each chart which would run when that chart is clicked on. This macro is identical for each chart except for the name of the chart being passed.
Sub Chart1_click() ShowChart "Chart 1" End Sub
Sub ShowChart(c As String) frmChart.Show End Sub
In the UserForm_Initialize code located in the userform module, I'd like to call the code which saves and loads the image of the clicked on chart. But here's where I'm stuck. How do I pass c to the code in the form module...e.g, how to pass c to UserForm_Intialize and to ChartZoom? Here's what I have so far...
Private Sub UserForm_Initialize(c As String) ChartZoom c End Sub
Private Sub ChartZoom(c As String)
Dim Cht As Chart Set Cht = ActiveSheet.ChartObjects(c).chart Dim CName As String CName = ThisWorkbook.Path & "cht.gif" Cht.Export Filename:=CName, FilterName:="GIF" imgCht.PictureSizeMode = fmPictureSizeModeZoom imgCht.Picture = LoadPicture(CName)