Completing This IF Code

Feb 19, 2009

situation: if cell I22 in Sheet1 = "MFRHTC", a message box will pop up and give the user some info and at the same time ask if this is a Fed Ex shipment

if user selects NO, then nothing will happen

if user selects YES, then the user willl be directed to cell L15 in Sheet2 in order for them to input their ship to address

here is what I have so far:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("I22"), Target) Is Nothing _
And Target.Value = "MFRHTC" Then
Msg = "Units will provide the following in order to have ammunition Fed Ex to HTC's " & vbCrLf
Msg = Msg & "" & vbCrLf
Msg = Msg & " POC" & vbCrLf
Msg = Msg & " Unit ship to Address / CANNOT BE A P.O. BOX" & vbCrLf
Msg = Msg & " Phone Number" & vbCrLf
Msg = Msg & "" & vbCrLf
Msg = Msg & "" & vbCrLf
Msg = Msg & "Input the required info in the Fed Ex ship to address Box"
MsgBox Msg, vbInformation, "FED EX AMMO INFO REQUIRED"
If MsgBox("IS THIS A FED EX SHIPMENT REQUEST", vbQuestion + vbYesNo, "SELECT EITHER YES or NO") = vbYes Then

End If

End Sub

View 9 Replies


ADVERTISEMENT

Not Completing Sub - Skipping To Another Sub

Mar 16, 2012

I have the following coding that I have tried in both the Sheet code and as a module at different times.

Sub CopyEmployed()
Sheets("Employment").Select
Range("A3:L200").Select
Selection.ClearContents
Range("D4").Select
Sheets("Act1").Select

- And there will be more here when I can get this first part working-

When I step through this works up to "Selection.ClearContents" but then ignores the next two lines

Range("D4").Select
Sheets("Act1").Select

and goes straight to the Private Sub coding below that I am using to change the sheet tab names (This is in the ThisWorkbook section and works perfectly)

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim LinkedCells As Range
Dim ArrayOfMatchingSheets As Variant
Dim i As Long
Set LinkedCells = Sheets("Menu").Range("E8:E22")
[Code] ....

I can continue to step through this until it eventually returns to

Range("D4").Select
Sheets("Act1").Select

It may then run the remainder of the coding but what I have tried so far produces more Runtime and type mismatch errors which I will post after I can fix this.

Bottom line is I dont want the change sheet tab code run - I need the remainder of the Sub CopyEmployed() to run.

View 9 Replies View Related

Loop Not Completing All Loops

Jul 3, 2007

Im using the following code to assign numerical values to words in two columns, then multiplying the values together and painting a cell with a specific color assigned to the final number. The problem is it wont do this past row 19

mLastRow = Sheet3.Cells(Rows.Count, "I").End(xlUp).Row
For m = mLastRow To 5 Step -1
' assign numerical values to the words in these columns
e = 22
r = 23

' Give Extent a value
If Cells(m, 9) = "Minor" Then
Cells(m, e) = 1
End If
If Cells(m, 9) = "Moderate" Then
Cells(m, e) = 5
End If
If Cells(m, 9) = "Serious" Then
Cells(m, e) = 8
End If
If Cells(m, 9) = "Critical" Then
Cells(m, e) = 10
End If....................................

View 4 Replies View Related

Completing Footer From Initial Userform

Oct 21, 2009

We currently use Excel to make reports of data obtained in field surveys. General data is repetitive throughout report. We have a title page, general particulars (GP) page, table of contents then data table pages. Each data page has info from general particulars page. i.e project name, date, inspector etc. Right now some cells of data table pagess have formulars pointing to applicble cells on GP page.

Presently I am designing a userform to input title and GP page data. So far OK.

Question: Can I take input on userform and add to footer. Info to be added after or inserted within text already there? i.e. Surveyors Name: ?(left footer) something center and something right. What type of code needs to be added and where do I place it .

View 9 Replies View Related

Completing IF Function With Date And Time As Inputs?

Jan 16, 2014

Using the attached doc, and its legend tab, I need the following columns corrected as I am seriously tripping up on formats vs inputs for outputs.

1.) Column "N's" result based on the duration output of the preceding column "M" is:

<=4 = 40
5 = 30
6 = 20
>=7 = 10

2.) Column "Q's" result based on the duration output of the preceding column "P" is:

<=18 == 40
>=19<=24 == 30
>=25<=48 == 20
>=49 == 10

The legend tab shows the info as well.

View 3 Replies View Related

Excel Not Auto-completing Long Word?

Jun 24, 2013

I have to type in a long place name with 10 letters repeatedly and whereas before Excel completed it after I typed the first two letters it has now stopped doing so. Is there a way to reactivate this facility? Other names do get auto-completed when typed in the same column.

View 3 Replies View Related

Completing Probation Period This Week From Join_Date

Feb 5, 2007

I have got Names in column A and Join_Date in column B. In column C I want those whose Probation period is going to finish this week. Probation is of 90 days.

View 9 Replies View Related

Completing Range Of Cells Based On Data On Another Sheet Prompted By Dropdown Selection

Mar 23, 2014

First sheet has a client name and several cells of data along the same line. All of the data on this sheet is kept long term.

The second sheet is completed copied and deleted. In completing the second sheet the client name is selected of a drop down list and pulled from sheet one.

What I want to do and not sure if there is a way is that when I select a client and populate it on sheet two I would like the related data on that clients line from sheet one to populate to same named lines on sheet two.

if this is possible and if so provide a brief description of how it would work

View 3 Replies View Related

Excel 2007 :: Spreadsheet To Track Group Timeline For Completing Strategy Meetings With Customers

Apr 30, 2014

How to use conditional formatting in Excel 2007 (). I'm creating a spreadsheet to track my group's timeline for completing strategy meetings with our customers. When we have a meeting, I will enter the date of that meeting in a specific cell. In a successive column(s), I'd like for a cell(s) to turn a specific color based on the length of time from the last meeting (or if there is no date for a meeting entered - i.e. no initial meeting has been set).

View 9 Replies View Related

2002 Code V 97 Code: Add A Small Workbook Open Event Code Which Works For Me But Debugs For The Others

Jan 27, 2009

I use excel 2002 but some of my office are on 97, i want to add a small workbook open event code which works for me but debugs for the others?? The code is basically, go to a tab, on that tab and that range sort..

View 2 Replies View Related

Cracked Vb Code: Prevent People From Accesing The Code I Protected The Code Blocking It From Visualization

Feb 8, 2007

I've developed a little software using Excel Macros & VB. To prevent people from accesing the code I protected the code blocking it from visualization. It seems not enough as an acquaintance of a friend cracked it in 25 minutes. Or so he says. So I'd like to know if there is a better way to protect the font code.

View 8 Replies View Related

Pick Up The Vendor Code Of Part Code From Looking Highest Quantity Of Part Code

Mar 9, 2013

I have an excel file having part code,name,vendor and Qty ( Quantity ).

My problem is that I want to apply an excel formula to pick up that vendor code who have highest Qty of a part code.The condition is that S.No.should not be disturbed.This file is so large,but here I have taken an example,

View 2 Replies View Related

Calculations To Manual Before My Code Runs And Set It Back To Auto When My Code Is Done Running

May 12, 2009

I am dealing with several very large spreadsheets using VBA to do various things. I found that my code worked well, but was taking a long time to run. The biggest time consumer was my use of the AutoFilter features. I have since turned calculations to manual before my code runs and set it back to auto when my code is done running. What are the potential consequences of my turning calculations to manual and then back to auto?

View 2 Replies View Related

Excel 2010 :: VBA Code To Extract HTML Source Code Not Working On Google Sites

Dec 6, 2012

I have previously used the following code to successfully pull out IE webpage source code for string manipulation.

Its a crude example to demonstrate the principle:

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public IE As Object
Sub Sample()
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

[Code] ......

However when I substitute in a Google websites address into the IE.Navigate command, the code runs to the "Source_Code = IE.document ...." line then flags up a Microsoft Visual Basic error. "Run-time error '438': Object doesn't support this property or method"

The webpage that I am trying to access is a confidential company site, so you won't be able to access it yourself, but starts with [URL] ......

The one thing that I have noticed about this website is the Privacy Report icon in the lower right status window (Picture of an eye with a restricted symbol in front). I don't know whether this is the cause of my problem, or purely an incidental observation.

Is there something peculiar with Google sites that means that the source code cannot be extracted in general, or is this an issue specific to my site ? Does the Privacy Report icon have any relevance, and if so how do I switch that off ?

Using :
MS Excel 2010
IE Explorer 8.0

View 1 Replies View Related

Have Code To Block Save But How To Keep Code In Workbook Without Saving The File

Aug 1, 2013

My company has files that are already in use. I don't know too many details about how they work, but somehow saving the file will screw it up and my boss has to go back and reset something or other to correct it. Obviously it's connected to some other software somewhere. The code below will block Save and Save-As. BUT how do I get the file to hold onto the code without actually saving the file after the code is added (since the file shouldn't be saved)?

VB:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI = False Then
Cancel = True

[Code].....

View 1 Replies View Related

Passing Variables And Values Between Sheet Code And Module Code

May 13, 2009

I have some buttons in different sheets in an excel file, each button has its own code, that is the reason I can not move the code related to each object to another location (sheet or module).

And I have one piece of code in Module1 (Auto_load) in order to execute automatically this routine every time file is opened. Inside "auto_load" routine I initialize some values of some check buttons,options buttons and positions of some objects in diferent sheets, but I can not pass the value of variables between Module and Sheet's code even when I declare as public variables and/or function.

I have the following structure: ...

View 11 Replies View Related

Code To Delete Rows Based On Status Code In Column

Jul 24, 2009

I'm trying to write a VBA script which will delete all rows in my Excel spreadsheet where Column I (which contains a status code) does not contain the word "Completed".

At the moment, I'm doing this the other way round: my script is able to search for entries in Column I which contain the status codes "Pending", "Awaiting Authorisation", "In Progress" etc and delete them. The idea is that when all those rows are deleted, I'll only be left with rows which have a status of "Completed". This works fine at the moment. However, the concern is that if a brand new status code is added to the data file, my script would be unable to pick it up and delete it. This is a small sample of the code I'm currently using (which deletes all the rows with statuses other than Completed):

View 4 Replies View Related

Worksheet_Change Code: Determine How To Get The Code Below To Fire Whenever Cell J10 Is Populated

Jul 30, 2009

I am trying to determine how to get the code below to fire whenever cell J10 is populated and do nothing when cell J10 is not populated but I can't quite get it. (Cell J10 is manually changed and is not changed based off of a formula)

View 4 Replies View Related

Standard Way To Organize Sections Of Code With Code Tags?

Jul 25, 2014

Is there a standard way to organize sections of code with code tags? Due to the nature of my work, there is a lot of documentation involved. And, my spreadsheets rely heavily on VBA. These code tag sections will be going into a design specification, so that there is a layer of traceability from the document to the program. These are the general sections or item numbers that I've come up with.

1. Dimensions and Variables

2. Data

3. Processing the Data

4. Rules of analysis

5. Analysis

6. Formatting

I guess I'm looking for something standard like UML diagrams for DFDs, but with tagging code to break them up into sections?

View 4 Replies View Related

Using Code To Email A Sheet But Need To Strip The Code Before Sending

Feb 2, 2009

I am using the code below that I got off of these forums to email a particular sheet in my workbook, but I need to strip all of the VBA code and the command button from the sheet being sent.

View 14 Replies View Related

Understanding Code (code In Eglish Specially After The .Count /14-1)

Feb 6, 2009

Can someone explian to me this line of code in eglish specially after the .Count /14-1

View 2 Replies View Related

VBA Macro Code Needed To Run The Code Contained Within A Cell

Dec 17, 2008

I have a macro that, when run, needs to read the contents of cell B5, and run the code that it contains.

Cell B5, for example, would contain the text:
Range("B13").Formula = "SUM(D12:D14)"

I need a macro to "execute this code", as if it were in the macro itself.

I have assigned the above to a variable, but am not sure how to execute it.

EG.


Dim the_calc
the_calc = Range("B5").value

Now, how do I run the_calc ?

View 9 Replies View Related

Change Text Code To Numeric Code?

Apr 3, 2014

I have problem to change text code into numerical code using macro. i have data contain text code and i would like to convert it into numeric . each text code has dedicated numerical code for example I have 4 fluids with text code text code:

FW = Fresh water
SW = Saline eater
CW = connate water
MW = Meteoric water

numeric code as follow

FW=1
SW=2
CW=3
MW=4

I would like to convert the text code into numeric code, it is easy if using excell , but it is routine job for me , i need to create macro to be more simple .

View 1 Replies View Related

Adding Code: Combine 2 Sections Of Code

Sep 9, 2009

I am now trying to combine 2 sections of code but being a complete VBA novice I'm stuck, where should the second Sub go so that it works,

View 4 Replies View Related

Efficient VBA Code Vs Macro Recorder Code

Sep 9, 2007

What is the most efficient VBA code for the following macro recorded codes? I wish to write more efficient code versus the lengthy, cumbersome macro recorder code.

1) Macro Recorder Code to Copy One Sheet to Another

Sheets("Data Apple").Select
Cells.Select
Selection.Copy
Sheets("Banana").Select
Cells.Select
ActiveSheet.Paste

2) Macro Recorder Code for Replacement Purposes......................

View 9 Replies View Related

Code Execution Has Been Interrupted (code Halts)

Sep 12, 2008

I have been trying to track down why this message keeps on popping up, doesn't matter what excel file I open it always pops up, code will halt at different times in the code.

View 9 Replies View Related

VBA Code- Results Can Be Obtained Without Having To Run The Code

Jul 14, 2007

I am looking for VBA code by which the results can be obtained without having to run the code. For Instance, if Z = X*Y, I would like the code to automatically calculate Z for as soon as the value of X and Y are changed.

View 10 Replies View Related

Code For The FuzzyPercent Code As A Module

Jan 10, 2006

I have implemented the code for the FuzzyPercent code as a module and Excel will not recognize the function for the cell (=fuzzypercent($C$3,$B5,D$2)). I am using Excel XP.

View 9 Replies View Related

Put Hyperlink Code In This Button Code

Dec 5, 2007

Sub Increment()
Dim Lr As Long
Lr = Cells(Rows.Count, "A").End(xlUp).Row
If IsNumeric(Cells(Lr, "A")) Then
Cells(Lr + 1, "A").Value = Cells(Lr, "A").Value + 1
End If
End Sub

This adds 1 to the previous cell and displays in the next available cell.

How could I make it sao that when this number enters in the cell it hyperlinks automatically to the master file?

Before this button was introduced I used this:

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error GoTo Err_App_WorkbookBeforeSave

Dim hl As Hyperlink

For Each hl In Me.Hyperlinks
If Wb.FullName = hl.Address Then
Application.EnableEvents = False
Cancel = True..............

View 9 Replies View Related

VBA Code- How Do You Get The Code Boxes To Appear In Threads

Feb 19, 2008

I have code that inserts columns, inserts formulas, and then copies the formulas to the last row of data. It all works good but for some reason, the columns that are being copied, are being copied past the last row of data. It can always be determined how far down it will be copied. Examples: if the last row of data was row 4, then the formulas would be copied down to row 24, if the last row of data was row 54, then the formulas would be copied down to 254, if the last row of data was row 284, then the formulas would be copied down to 2284. I can not figure out how and wh this is happening, but whatever the last row of actual data is on the spreadsheet, there is a 2 being placed in front of the last row of data and the formulas are being copied down to whatever the last row is with the addition of a 2 in front.

Here is the code for the columns additions, and formulas:

Columns("O:S").Insert Shift:=xlToRight
Columns("W:Z").Insert Shift:=xlToRight
Columns("AB:AF").Insert Shift:=xlToRight
Columns("AH:Al").Insert Shift:=xlToRight
Range("O2").FormulaR1C1 = "=CONCATENATE(RC[1],""/"",RC[2],""/"",RC[3])"
Range("P2").FormulaR1C1 = "=IF((RC[3]=7),LEFT(RC[-2],1),LEFT(RC[-2],2))"
Range("Q2").FormulaR1C1 = "=IF((RC[2]=7),MID(RC[-3],2,2),MID(RC[-3],3,2))"
Range("R2").FormulaR1C1 = "=RIGHT(RC[-4],4)"

Lets take this first one for example:

Range("O2:S2").Copy Range("O2:S2", Range("O2:S2" & Range("A" & Rows.Count).End(xlUp).Row))

If the last row of data was row 54, then columns O:S would have the formulas copied down to row 254.

How can this code be modified so the formulas will not be copied past the last row of data?

How do you get the code boxes to appear in these threads. I do not know how to do this. As you can see, all I did was copy and paste my code in this thread.

View 9 Replies View Related







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