Looping- Loop To Force A New Date Install Via A Input Box

Jan 7, 2010

The code below first asks a user to input a weekending date (which must be a Saturday). The value of the input box goes to cell C1 of my spreadsheet. That part works fine. I also have a function in Cell G1 with the function:


=TEXT(C1, "dddd")
I don't know if this is the best way to test for a Saturday but it is what I have,

Where is goes bad is if the date is not a Saturday. I have a loop to force a new date install via a input box but it won't update C1 with the inputed data to recheck for the Saturday value. Below is the whole code I am working with...


Dim aa As String
Dim bb As String

If Range("C1") = "" Then
Do While bb = ""
bb = InputBox("Please Enter a Weekending Date!")
Loop
Range("C1").Value = bb
End If
If Range("G1") "Saturday" Then
Do While aa "Saturday"
aa = InputBox("Weekending Must Be a Saturday. Please Enter a New Weekending Date")
Loop
Range("C1").Value = aa
End If

View 9 Replies


ADVERTISEMENT

Retrieve Windows Install Date From Registry?

Mar 23, 2014

how to retrieve Install date of Windows from registry (or form any where else). I know this date is saved in key "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionInstallDate", I used RegRead but it return "0" (zero)

View 6 Replies View Related

Force Numeric Input

Jul 21, 2006

I want to force the user to input a numeric value in a textbox and for a message to pop up if a letter is typed, what code do i use?

View 9 Replies View Related

Userform Form Force Input

Jan 9, 2012

I have a series of Userforms that I would like the user to be forced to enter in some sort of information in one of those userform in the series. I do not want it to be submitted blank. Is there a code or a properties toggle to make this possible.

Code:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Sheets("MDF").Select
Range("RailcarNumber").Value = TextBox1.Value

[Code] .......

View 4 Replies View Related

Force Upper Case In Input Box

Mar 12, 2007

I have a series of input boxes and in one particular input box ("TypeScore") if the lower case is entered I want to convert it to upper case. Here is a small snippet of the series of input boxes. I have tried just about every suggestion I can find on this forum, but can't get it to work.

View 9 Replies View Related

Force Data Input In Specific Fields Before Exit

Mar 22, 2007

I have an excel sheet that has two text fields "A2" 2 digit (Month) and "B2" 2 digit (Day of week), both are currenlty in a text format. I need to force the users of this sheet to enter values in both of these fields prior to saving. Is there a simple macro that I can run to check these fields.

View 8 Replies View Related

Do While Loop Not Looping

Sep 22, 2007

Another question...

I want to organize the data by broker then by security, I created the following code to do the looping...but it stopped loop and generated information for one broker....Do you know what is wrong with my code?

I also want to sum the results of cell (A,7) based on broker...basically I want to insert a new row to sum the results of one broker, before going to the other...how should I do that also?

Sub OJOM1()

Dim A As Integer
Dim B As Integer
Dim Broker As String
Dim OJOMM As String

A = 2

'Do While Worksheets("historydata").Cells(A, 1) <> ""
B = 1

Do While Worksheets("BrokerList").Cells(B, 1) <> ""
If Worksheets("BrokerList").Cells(B, 1) = Worksheets("historydata").Cells(A, 6) Then
'= Worksheets("BrokerList").Cells(B, 1) Then
Broker = Worksheets("BrokerList").Cells(B, 1)
'MsgBox Broker
Do While Worksheets("historydata").Cells(A, 1) <> ""
If Worksheets("historyData").Cells(A, 6) = Broker And Worksheets("historydata").Cells(A, 2) = Worksheets("MarginReq").Range("B4") And Worksheets("historydata").Cells(A, 3) = Worksheets("MarginReq").Range("B5") Then
Application. ScreenUpdating = False
Worksheets("historydata").Cells(A, 6).copy Sheets("MarginReq").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Application.CutCopyMode = False
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Worksheets("historydata").Cells(A, 7).copy Sheets("MarginReq").Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
Application.CutCopyMode = False
Application.ScreenUpdating = True
End If
A = A + 1
Loop
End If
B = B + 1
Loop
'A = A + 1
'Loop
End Sub

View 4 Replies View Related

VBA Store Input Box Value Before Looping Through Worksheets?

Feb 4, 2014

The problem with the code below is that it re-prompts the input box for each worksheet that the macro runs through.

What I would like to happen is the Input box appear at the begin, and that value is stored and then the same value pasted into A2 on each worksheet.

Code:

Dim ws As Worksheet
For Each ws In Worksheets
Rows("1:1").Insert Shift:=xlDown

[Code]....

View 2 Replies View Related

Loop Thru Worksheets Not Looping?

Aug 12, 2009

Why wont this loop thru all worksheets? It seems it runs worksheet named "Monday Wk (1)" for each sheet and no others.

View 9 Replies View Related

Loop Wont Keeps Looping..

Feb 9, 2010

I am doing wrong here, the code seems to keep looping. I broke out of the search and its found the correct information and copied the correct rows, though looped and did it again, and again, and again,

View 2 Replies View Related

Loopy Loop Keeps Looping

Feb 12, 2009

I can't work out why this keeps looping. Can anyone help, please? Thanks.

Sub Test3()

LastRow = Range("B65536").End(xlUp).Row

Do

Do
ActiveCell.FormulaR1C1 = "=R[-1]C"
ActiveCell.Offset(1, 0).Select

Loop Until Not (IsEmpty(ActiveCell.Offset(0, 0)))

ActiveCell.Offset(1, 0).Select

Loop Until ActiveCell.Row = LastRow

End Sub

View 9 Replies View Related

Looping: Run The First Macro An Error Pops Up Saying That A Variable Within The Loop Is Not Set

Mar 27, 2007

the following code should determine whether the searched value can be found in more than just one row and than enlist certain values from each of those rows in ComboBox4 using a loop. Then I have a second macro which would assign appropriate values from a Sheet to other text boxes whenever one changes the value of the ComboBox4:

Private Sub ComboBox2_Change()
Dim vFind
Dim Firstaddress
Dim rFound As Range
Dim wsName As String
Dim SrchRng As Range
wsName = Me.ComboBox1.Value
With Worksheets(wsName)
vFind = UserForm2.ComboBox2.Value
Set rFound = .Range("B1")
Set SrchRng = .Range("B:B")
Option Explicit
End With...............................

While trying to run the first macro an Error pops up saying that a variable within the loop is not set. I've got no idea how to fix it

View 9 Replies View Related

Force A Date Format

Mar 15, 2007

I don't why the following code is not working. I am trying to force a date format when a user is trying to enter a date in anycell

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If IsDate(Target.Value) Then
Application.EnableEvents = False
new_date = Format(Target.Value, "dd/mm/yyyy")
Target.Value = new_date
'MsgBox new_date
Application.EnableEvents = True
End If
End Sub

View 9 Replies View Related

Add Loop To Input Box

Apr 16, 2009

I have an input box that request the user to enter a vlue between 1 and 6, and uses the answer to multiply another range of cells.

Now I'm not sure how to add a couple of other features. I would like to:
1. Loop the input box until an acceptable answer is given, (numeric, between 1 and 6), with a message box prompt that says "Try Again".
2. Exit the macro if the user hits "Esc".

Here is my current

View 6 Replies View Related

Force TextBox To Be Date Format?

Apr 30, 2008

I'd like to import some dates into some textboxes on a userform.

I'm also going to let the user edit these, however... what i'd like is for the user to be forced to:

1) enter a date in the format dd/mm/yy
2) Enter a valid date (eg, not feb 30th)

View 9 Replies View Related

Force TextBox To Be Date FormatE

Apr 30, 2008

I'd like to import some dates into some textboxes on a userform.

I'm also going to let the user edit these, however... what i'd like is for the user to be forced to:

1) enter a date in the format dd/mm/yy
2) Enter a valid date (eg, not feb 30th)

View 9 Replies View Related

How To Input If Statement In For Loop

Jul 31, 2013

I have a code like this below

Sub Copydata()
Dim emre As Integer
For emre = 100 To 121
Sheets("CP TB").Select
ActiveSheet.Range("$B$8:$G$10000").AutoFilter Field:=3, Criteria1:=emre
Range("E8:F8").Select

[Code] .....

I want to skip values when the selection is a value I choose. I tried to put a "If" statement but I couldn't make it work.

The IF statement will check the selection after red colored code. if cell value is "a" then it will go for Next emre.

View 6 Replies View Related

How To Force TEXT To Return Date In English

Feb 6, 2014

I have a formula as follows:

Code:
=TEXT(A1,"Mmm YY")

Where cell A1 contains a date, say 01/01/2014.

For me this returns "Jan 14." However, I have a colleague using a Spanish version of Windows/Excel and therefore it displays this in Spanish as "ene 14."

How can I force the formula to return the English spelling, Jan 14?

View 2 Replies View Related

Force SaveAs As Cell Text & Date

Jun 7, 2007

I have a customised excel woorkbook that will be distributed to several locations with different computere systems, etc. I wanted to keep some convention with the naming, so I've put in a saveas routine to open the saveas dialog and change the default name. The user can then select the directory location and save the file.

Here's the
Sub Saveas_routine()
'
Dim strName As String

On Error Goto InvalidName
strName = "E-RAMP " & Sheet1.Range("A1") & Format(Now, " dd-mmm-yyyy") & ".xls"
Application.GetSaveAsFilename (strName)
Exit Sub

InvalidName: MsgBox "The text: " & strName & " is not a valid file name.", vbCritical, "E-RAMP"
End Sub

The problem is, when the save button is pressed in the saveas dialog, the dialog disappears and the the workbook doesn't save.

View 9 Replies View Related

Force Date Format Entry In Text Box

Sep 5, 2007

A form loads and the first thing the user is to do is enter a specific date in a text box (preferably in, "mm/dd/yyyy" format.)

Is there any way to set up the text box so that when the form loads, the, "/"'s (slashes) are already in place? And can I set it up so that if the user enters in the date in any other manner aside from, "mm/dd/yyyy", that it will give them an error?

Finally, I want the user's date input to store on a worksheet (in row, "G".) So the first time the user uses the form, they type in a date and it stores the date in the FIRST AVAILABLE CELL IN ROW, "G." (example: "G1") The next time they use the form and type in a date, it is to store in, "G2", then in, "G3", ect. Each time they fill out the form, the new entry is to save in the next row beneath the previous entry.....

For other text boxes and combo boxes I have been using the following code to do this:

Sheets("Sheet1").Range("A" & intRow) = Text.Value (or Combobox.Value - depending on whether it was a text box or a combo box.)

Unfortunately I have NO idea how to apply this logic in regards to text boxes that are to store dates.

View 9 Replies View Related

Prevent Editing After Date And Force Enable Macros

Apr 7, 2014

So I have a Workbook that I want to make read-only/protect after a certain date. I also want to force the user to have macros enabled. So far I have the following script, but despite changing it to read-only it doesn't seem to do anything. I have also tried to enable protection on the sheets after that date, but am getting errors.

View 2 Replies View Related

Loop Through Range Find Value Input Box?

Jun 20, 2012

I have a range (C3:C56). I have a set number in each of these cells. I also have a range out to the side that calculates a number after input a % in cell BI2. The formula reads as "=AE3-(AE3*$BI$2)". Basically it is reducing the values in my range. If a number is in my range is 8 and i input 25% in cell BI2, then my result would be 6.

I have a few steps I want to happen with this range.

1 Display an input box asking for a percentage
2 I want to loop through my range and use that percentage to reduce the numbers
3 (optional but would be amazing to have) after the reduced value is determined, round down to the nearest multiple of 4.

View 9 Replies View Related

Cancel OR Loop Input On Worksheet Name

Jan 27, 2014

I am trying create a macro which asks for the Sheet name as an input for a Sub. I've gotten it to work but there is just one problem: The Cancel button does not work on the MsgBox. Everything else works just as I want to: it shows a dialog box to enter a name for the worksheet and if the worksheet does not exist, it loops and shows a message saying that it does not exist.

However, the cancel button does the same thing as entering nothing in the box and it does not end the process. I would want it so that the cancel button kills the process. Here is the code:

Code:
Option Explicit
Function WorksheetExists(WSName As String) As Boolean
On Error Resume Next
WorksheetExists = Worksheets(WSName).Name = WSName
On Error GoTo 0

[Code] .......

View 2 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

Entering Input And Clicking Buttons During Loop

Mar 22, 2009

I am basically creating a questionnaire style program where the user gets asked 50 questions, one by one and they input their answer and press another button (submit button). They initially press a start button to start the questionnaire.

So far, I have created a range of questions and it fills one row where the questions are entered. In intend to use a for loop to go though all 50 questions.

Now this is where I’m stuck. I have a submit button and after each question is displayed, I want the user to enter their answer and then click the submit button to then continue to the next question.

However, I can’t think of how to do this.

1.Firstly, how can I loop through the questions and yet allow the user to input their answers after each iteration?

2.Also can I even click the submit button during the loop phase? I.e. when already running.

View 3 Replies View Related

Refresh Input Cell And Capture All Outputs From Each Loop

Jul 10, 2014

Assuming I have three worksheets:

1) input: col A has a series of product code (string)
2) calculation: where I want to automatically copy and paste each product code from "input" worksheet into "calculation" cell B4, and through many steps of calculations, return the outputs in cell B8 and B9 (parameters are numeric)
3) output: how to automatically record B8 and B9 from "calculation" sheet to this sheet Row 5 and 6 from each loop? (format of output doesn't really matters)

View 4 Replies View Related

Macro To Install Add-ins

Sep 14, 2006

I am running a fairly complex simulation at work and have quite a few different functions in it. For the simulation to work properly, i need to have the Solver add-in and the Analysis ToolPak installed. Everytime that i try and use the simulation on a different computer (or if anyone else tries to run it) the add-ins must be enabled again. Is there a way to set up a macro to enable them when either i open the simulation (first preference) or when a button is pressed (2nd preference).

View 5 Replies View Related

Installshield To Install Add-in

Sep 14, 2007

Has anyone ever used InstallShield to install an Excel Add-In?

View 2 Replies View Related

Vlookup Looping (for Each...next?). Vlookup Loop Technique

Jul 24, 2009

I have data in a pivottable which I want to compare with another table. The lastcolumn+1 of the pivottable needs to get data from another table. I have this for an example:

View 5 Replies View Related

Use VBA To Install Excel Reference

Nov 7, 2011

I was wondering if there was a way to use the Workbook_Open() event in Excel to install specific references. I tried to record a macro, and then open the VBA editor and then see what code it showed to install, but there was no code in the macro

I tried:

Code:
With Workbook.reference
.AddFromFile "C:WINDOWSsytem32.stdole2.tlb"
End With

Which is just giving the location of the reference I want to install, and It gives a debug error of Run Time Error 424 Object Required

View 9 Replies View Related







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