Shortening Code

Mar 20, 2008

How would I make the following code shorter/ more efficient? The columns don't vary much - either B, G or L. The rows vary a bit more....

View 9 Replies


ADVERTISEMENT

Shortening Code With Loop

Jan 16, 2007

How would I shorten this code using a loop and arrays? It is working correctly but needs to be shortened down.

Sub cr()
Dim j
Cells(1, 1).Interior.Color = RGB(250, 155, 100)
j = 0.09
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.094
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.043
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.05
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.034
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.032.........................................

View 4 Replies View Related

Shortening Code To Copy Several Values

Jan 17, 2007

I have put together some code which works fine but is very clumsy and, when it comes to expanding it in the very near future, will look really bad.

rn = Worksheets("Test"). Range("C1").End(xlDown).Offset(1, 0).Row
Worksheets("Test").Range("C" & rn) = Odate 'a variable already created
Worksheets("Test").Range("D" & rn) = Range("E8")
Worksheets("Test").Range("I" & rn) = Range("E4")
Worksheets("Test").Range("K" & rn) = Range("D6")

Is there a s way to simplify this code (and the several more lines of similar) using For..Next and/or With function(s)? I've tried a few combinations but can't quite strike the right one.

View 2 Replies View Related

Shortening My Code For Multiple Case Scenario

Jul 3, 2007

I have a combo box that is used very simply to select a column from sheet and copy that whole column down to where text ends into a specific column in another sheet. I.e whatever column is selected ends up in column B of this other sheet. At the moment I've been using If functions for each case but there must be a more efficient way of doing this; here is just a sample of my

If textseries1.Text = "Fund01" Then
With Sheets("data")
Range("C1:C" & Cells(Rows.Count, 1).End(xlUp).Row).Copy
End With
Sheets("calculations").Range("B1").PasteSpecial
End If

If textseries1.Text = "Fund02" Then
With Sheets("data")
Range("D1:D" & Cells(Rows.Count, 1).End(xlUp).Row).Copy
End With
Sheets("calculations").Range("B1").PasteSpecial
End If

If textseries1.Text = "Fund03" Then
With Sheets("data")
Range("E1:E" & Cells(Rows.Count, 1).End(xlUp).Row).Copy
End With
Sheets("calculations").Range("B1").PasteSpecial
End If

There are about 75 columns in total but thought it would be a little repetitive to put it all up here!

View 2 Replies View Related

Shortening VBA Code Of Copy / Paste Values With Transpose

Aug 11, 2014

I think I have a very straight forward problem, I'm copying about 400 values from one workbook to another (from vertical range to horizontal range) and I currently have about 400 lines of code in order to do this. Below I've pasted the code I'm using now but the macro takes an estimated 30 seconds to run. I figure if I can reduce the number of lines the macro will run a lot faster

RowCount = openWb.Sheets("Library Raw Shear Rates").Range("A3").CurrentRegion.Rows.Count
With openWb.Sheets("Library Raw Shear Rates").Range("A3")

[Code]......

View 3 Replies View Related

Shortening VB Code That Deals With Deleting Row If Type Of Word Is Found?

Sep 17, 2012

I have a file with over 20,000 rows that contain a date (Mon~Sun), What I need to do is remove every day that contains Mon~Sat and only keep Sun, this is the code that I have come up with and is working.

Code:
Dim c As Range
Dim SrchRng
Set SrchRng = ActiveSheet.Range("A1", ActiveSheet.Range("A" & Lastrow).End(xlUp))3

[Code]....

View 1 Replies View Related

Shortening A URL

Jun 1, 2007

I have a very long column (almost 3000 cells) of URLs. I would like to replace them in the second column with shortened versions, basically cut them at the fourth slash.

how can I used functions in Excel to do it?

View 10 Replies View Related

Shortening Text With MID

Apr 2, 2008

I'm using this function to make a short description of a product from a long description.

=MID(K2,1,200)&"…"

So it's taking the first 200 characters of cell K2 and adding a ... to it.

Whats happening is it is splitting words and ending at character 200 instead of the end of the closest word to character 200.

Is there a way to alter this formula to break at the end of a word close to character 200?

Or is there a better way to do this?

View 9 Replies View Related

Shortening Summation Formula?

Jan 10, 2014

I have attached a screen shot below of a sheet I am using to collate fruit orders and calculate an order total for each individual person.

Untitled.png

The price of each fruit item runs along row 3 and then each persons order has its own row. The total price for each person is then calculated in column AM. However I am looking to shorten the formula I am using to calculate the total in this column.

I am currently using:

AM4=SUM(C3*C4+D3*D4+E3*E5+F3*F5+........+AJ3*AJ5+AK3*AK5+AL3*AL5)
AM5=SUM(C3*C5+D3*D5+E3*E5+F3*F5+........+AJ3*AJ5+AK3*AK5+AL3*AL5)

As you can see this formula is far too long so I am looking to write it in compressed formula.

View 4 Replies View Related

Shortening Data For Printout

Feb 9, 2014

I have a letter and numbers in the A column. example: (A001_C108_1231Xb)

This kind of numbers go from Column A1 : A1800.

I need to print them out, therefore I would like to fill every page which has 50 rows and 3 columns : A, D and G to write in the data.

I tried to do it manually, which is quite some work.

View 5 Replies View Related

Shortening Recorded Macro?

Jul 15, 2012

shortening the below recorded macro?

Code:
Sub Macro1()
'
' Macro1 Macro

[Code].....

View 3 Replies View Related

Shortening A Speed Sheet

Apr 18, 2008

weekly i have a report that is generated that is over 5000 lines and 4 columns wide.

I currently copy and paste one page column to make it 16 columns across the page. Is there a function in excel to do this?

View 9 Replies View Related

Shortening A Macro (evaluates The Range )

Mar 14, 2007

I need a macro that evaluates the range H66:GI66.

In that range the following variables could exist:

A3, A4, A5, B3, B4, B5, C3, C4, C5, D3, D4...all the way to I5 for a total of 27 different combinations.........

View 9 Replies View Related

Combining 2 Vba's And Shortening The Processing Time

Jan 24, 2007

I have created 2 seperate VBA's that I would like to combine and improve upon. One removes Duffs, and the other eliminates blank rows. My goal is to do a copy and paste/special, then remove the duffs, and then delete all rows that do not have data in column H.

I have tried several VBA's listed on this sight, but cannot seem to get a VBA that does everything I need it to do, and do it quickly. I have attached an example of my spreadsheet.

View 5 Replies View Related

Shortening The Formula I Used For Calculating Number Of Public Holidays That Passed

Sep 25, 2009

I am using this formula to calculate a set of PH(Public Holidays) that have passed from a period of 1/4/2009 to 31/3/2010.

=IF(TODAY()>='Team Schedule'!D5,1.5,0)+IF(TODAY()>='Team Schedule'!D6,1.5,0)+IF(TODAY()>='Team Schedule'!D7,1.5,0)+IF(TODAY()>='Team Schedule'!D8,1.5,0)+IF(TODAY()>='Team Schedule'!D9,1.5,0)+IF(TODAY()>='Team Schedule'!D10,1.5,0)+IF(TODAY()>='Team Schedule'!D11,1.5,0)+IF(TODAY()>='Team Schedule'!D12,1.5,0)+IF(TODAY()>='Team Schedule'!H2,1.5,0)+IF(TODAY()>='Team Schedule'!H3,1.5,0)+IF(TODAY()>='Team Schedule'!H4,1.5,0)-4.5

From what u can see here, its a massive formula.... but I am pretty sure that there is a shorter way to key in the formula

*Note*
'Team Schedule'!D5-D12 and 'Team Schedule'!H2-H4 are PH. disregard the 4.5 that is in the formula as it is used for other purposes. Every PH that has passed will credit a 1.5 into the cell.

View 2 Replies View Related

Pivot Table - Show Report Filter Pages Shortening Tab Names Even When Character Is 31

Mar 4, 2014

I have an issue with a Pivot table: I am using the 'show report filter pages' function and prior to this I have ensured my character length of that field is equal or less than 31 however when I hit the function the tab names are shortened to 26.

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







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