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).............
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
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 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.
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?
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'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 try to add a named range and it says name not valid!! I'm putting in jan13. Why would this not be valid. There are no other named ranges in the workbook
Website has a URL where the last element is a number within a range (e.g. 1000 - 4000).
But the numbers are not sequential (e.g there are 100 pages, first URL ends "1001", last one ends "6000".
As shown below I set the code to cycle through every possible number:
VB:
For i = 1001 To 6000 With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://(whatever)" & i _ , Destination:="(Whichever cell the output starts in)"
Not the most constructive use of the national grid.
Is there a VBA that can check whether the URL "number" is genuine before doing anything else - and move straight to the next "i" if it doesn't exist?
I have this formula =COUNTIF(WallA,D35) which works great unless the named range is deleted. Is there a way to check to see if the named range is valid in formula?
The format for the sheet is set in stone and can't change, and therefore my macro's operate on set columns / rows amd cells.
Because the sheet is huge, im trying to figure out a way to only run the macro's that need to run and more specfically on the changed location.
The Question
I need to create a routine that on the user changing a cell, it returns the cell position (row,column), then it will call a routine i have already which decides based on the cell location, which macro to run and where.
I'm trying to make a listbox that contains a list of items from ranges that differ depending on the contents of one cell.
In other words, say the contents of the cell in question is 'flower' the listbox will be populated with the range of cells containing flower names; if the cell was 'shrubs' the same listbox would be populated with the range of cells containing shrub names.
I've scoured the site, but can't find an exact query that matches mine (though I've probably missed a bunch of them).
I have seen one of your posts in which you make a graph update based on dynamic named ranges. Here is my problem, I already defined the name of my ranges as:
I am trying to create a pivot table on a new sheet names as 4x4
I am getting following error:
Error : 1004 Reference Not Valid
I am not sure where is the problem. I have generated this code by using macro recorder and just changed the source and destination of the pivot generation code.
I have a named range that expands and contracts based upon the amount of data that is in some column. Call it AllData_UsedRange.
I have another named range that actually refers to a range. Call it AllData.
Column A Row2 56 Row3 44 Row4 65
AllData is a named range that refers to the range A2:A65536 AllData_UsedRange refers to A2:A4 by way of this formula. =OFFSET(AllData,0,0,COUNTA(AllData))
How to I obtain an address of AllData_UsedRange in VBA code?
These do not work... ThisWorkbook.Names("AllData_UsedRange").RefersToRange.Address Evaluate(ThisWorkbook.Names("AllData_UsedRange"))
I know that I can return the value of a defined name range, the address, and even the value of the define name, but if you are given a range address, how do you find its corresponding defined name in code?
I am trying to get the addresses of different cells containing numbers. This addresses should be ranked by the size of the value from largest to smallest. Currently I am using this formula
and just increasing the variable of the LARGE function for every rank. This works fine up to the point some numbers are the same. If I have for example two cells containing a 80 and 80 is the largest value, rank 1 and 2 result in the same address (of the first cell containing the 80). But I want the formula to result in specific addresses for every number. I thought about using MAX instead of LARGE, but I don't get a working solution for the second (third, fourth, ...) largest value.
I have a named range, called 'event' relating to cells a2-a200, I have a named cell, 'eventcounter'. I was hoping that I would be able to use the named cell eventcounter in formulae on the cells in the event range rather than having to use the cell address. So instead of having a formula that was something like this, =if(a3= etc etc.
I could refer to the range event and eventcounter. Eventcouter gets its value simply by counting the number of non blank cells in the event range, so consequently - I can only figure out how to address the last entry in the event range in the manner that i wish.
I have to macros I'm working with the first take a user set range and prints the . Address to a cell.
The second Macro I'm trying to get to look at that cell and pull out the range. So is there an opposite fuction to .
Address that will convert excel format to a VBA Range format. Ex A cell with $A$1:$A$2 to Range("A1",A2")
Macro 1
Code: For j = 1 To x c = 1 For i = 1 To ws.Range("AD" & rc).Value ws.Range("AE" & rc).Value = Application.InputBox (Prompt:="What is the Heading of Data set #" & c & " Table " & tc & " This entry may repeat", Type:=8)
[Code] .........
Macro 2
Code: 'A lot of code here but I want to be able to set multiple ranges to the ranges list in the cell values. rng(2) = sh(0).Range("AG2").Value
I am having troubles with using two methods together. I know how to find the address of the first or last occurance of a MAX in a range. I also know how to create a MAXIF function using criteria to determine what to consider for the max calculation. I do not know how to return the address of the result from the MAXIF.
I am using Office 2003 on WinXP.
Ultimately I want to take the address of the first result of a MAXIF and use it to do a lookup for a corresponding value. I'm not sure if I will be able to do this with a combination of functions, or if I will need a macro.
I have a variable which contains the column number. How do I then reference a range in VBA using that column number, as opposed to the letter? I know how to convert the number into the letter, but I also know there has to be something more simpler. For instance, a form of the ADDRESS function, but in VBA?
The Bs. consulting can take any values from business process like Bp1 or Bp1 or Bp2...
for this i have written validation macro
If Target.Address = "$C$21" Or Target.Address = "$D$21" Or Target.Address = "$E$21" Or Target.Address = "$F$21" Or Target.Address = "$G$21" Or Target.Address = "$H$21" Then
do the validation;
end if;
this works fine, but i need to use or condition , is there any better way to write this, a more compact way,
I need to select a variable number of cells on a line. I know Range("A2:c2") will do exactly what I need EXCEPT i need to use variables to do it. Is this possible, and if so how.
I want to define the range from a given cell and all data below within the same column strDataStart is the named cell in the worksheet that want to start from. Below is what I tried and failed.
Function rngDataCol(strDataStart As String) As Range Dim rngDataEnd As Range rngDataEnd = Range("strDataStart").End(xlDown) rngDataCol = Range(Range("strDataStart").Address, rngDataEnd.Address) End Function