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


ADVERTISEMENT

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

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

Code To Add New Row And Copy Formulas Only (not Values)

Jan 28, 2014

Im looking for code to add new rows and copy the formulas only (not values) into the cells A, B, C, D and F. I have found code that does this in various places online but in every case I have found they duplicate the row then remove the values (so the formulas are left behind). The issue I have however is that it triggers some change event code I have on the sheet which interrupts the process.

Is it not possible to simply insert a new blank row, then copy down the formulas only without values?

View 13 Replies View Related

Code To Look Values In Columns And Copy Every Entry

Jan 10, 2009

I have a sheet which is a reconciliation exported to excel from our in house system, what i am after is for the code to look at the values in Column F and Column I and copy every entry which is equivalent to $1million AUD TO Sheet AUD1M, I do have a sheet called Exchange_Rates in which the code can look into, they are all equivalent to 1 AUD. I have provided an example in Sheet AUD1M what the macro should do....

View 9 Replies View Related

Code To Run When Workbook Is Opened And Copy Values From Other Workbooks In It?

Feb 19, 2014

I want the code to run when we open excel workbook "TEST" and it should open up all the workbooks one by one in the folder J:ABC and copy cells C2 and C4 values in the A and B columns of TEST workbook.

e.g There are 5 workbooks in the folder J:ABC so when the TEST workbook is opened then the code should run and open 1st workbook and copy values in cells C2 and C4 to it and close the workbook.

The code should run as below:

1st workbook:

C2 value will go in Test workbook B1
C4 value will go in Test workbook A1

Close 1st workbook

2nd workbook:

C2 value will go in Test workbook B2
C4 value will go in Test workbook A2

close 2nd workbook.

3rd workbook:

C2 value will go in Test workbook B3
C4 value will go in Test workbook A3

close 3rd workbook.

and so on It will be going to next rows in A and B columns.

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

Copy/paste Values (copy Values Of Cells From B4 Till B-empty To C Column)

Jun 26, 2009

Sheet linked from external file, new data coming daily. How to copy Values of cells from B4 till B-empty to C column? The attached file has a properly displayed data.

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

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

Fill Values And Replace Told Values By Vba Code Depends Upon 2 Columns

Mar 26, 2014

I have set of data in multiple range ,need to fill the and replace the old values depends upon two column values (AH & AL)

IF Active Calls is "TATA" In AH:AH, and IF Action Onwer Col is "Blank",in AL:AL
Then Fill the Blank cells by Values "SVC" in the col Action Owner,Then Replace Old values by "Updates Awaited" in Status Col(AM:AM)

Find the attachment & basic code take this code for this task

[Code] ....

toggle-2.xlsb‎

View 5 Replies View Related

VBA - Copy Range With Multiple Same Values Based On Other Cell Values

Aug 31, 2012

I want to build a database where the user can select a specific time period. I have a static file with the time periods and the related values. For instance I have in column A1:A15 the time periods from January 2011 to Dezember 2011, but I have some dates multiple times as there are more values attached to it. For instance I have in the first 4 rows January 2011...what I want is when someone puts in the value January 2011 in cell B1 and Dezember 2011 in cell B2 that the whole static file gets copied to another location (including the multiple dates) displaying the chosen time period. Similarly if someone puts in the value March 2011 to November 2011, I want only those values to be copied.

View 4 Replies View Related

Select Range To Copy, Find Values And Copy

Feb 2, 2010

I have a base document that i can import another data document with a button (this is working).

I then have another WS ("search") in the base document with lots of identifiers which I want to use as my search range to look through the document that I just imported (column A).

I need a msg to ask the user what month they would like to find the $ value on (Ie, January) in the imported WS... this way it doesnt copy the entire line only cell in the selected month column.

Then I want to the user to be able to click a button that will check through the identifiers on the "search" WS and if the same identifier appears in the imported WS in column A, then for the $ value in the column selected to be copied to the search Range work sheet.

If the idenfifier is not matched then in place of the $ value copied can be the string "no in XXX WS" .

I have attached the document with dummy data in each work sheet with details more cleary what I have meantion above.

View 9 Replies View Related

Find Values, Copy, Check Date & Copy

Aug 6, 2007

The following macro does what it is designed to do and needs to be run from a control sheet called "Guide". When I run it from this Guide sheet it stops at around row 53 (out of 1400 rows) on each of the specified sheets in the macro. I have struggled with this problem and have now discovered that the macro will run correctly when run from one of the worksheets specified in the array, e.g. sheet "200 and 100".

Sub Calculateclosingtrades1()
Dim r As Long, c As Integer, LastRow As Long, rcheck As Long
LastRow = Range("J65536").End(xlUp).Row
Dim shtTemp As Worksheet
Dim vntName As Variant

For Each vntName In Array("200 and 100", "100 and 50", "50 and 25", "40 and 20", "20 and 10", "15 and 10", "18 and 9", "200 only", "100 only", "50 only", "40 only", "25 only", "20 only", "15 only").............

View 7 Replies View Related

Search Arrays For Specific Values And Copy "associated" Values To A New Location

May 26, 2006

Given the following data located in Sheet1 of a Workbook -

•I have seven columns (assume header row names are “A, B, C, D, E, F, G”) each containing numeric data in random order.
•All columns are of the same length (equal number of rows), followed by a blank cell, but the number of rows is unknown.
•Columns with header row names A-E will only contain numbers from 0 to 100, while F and G may contain numbers from -127 to +128.

Here is what I would like to do –

I would like to be able to analyze the data in columns A-D to locate rows that contain specific combinations of values (ex. row 41 contains the values 50, 0, 0, 0 and row 239 contains values 100, 0, 0, 0 in columns A – D, respectively, etc.).

For each row that is found to contain one of these combinations (there are many different combinations required), I would like to copy the associated values from columns E, F, & G for that row, and paste them into their respective (E, F, & G) columns located on Sheet2 of the same workbook. However, I would like to paste the E, F, & G values into a specific row order on Sheet2, DETERMINED by the value of the A – D combination identified on Sheet1.

Continuing with the ex. above, let’s say I would like to have the EFG values from row 239 in Sheet1 copied to row 10 in Sheet2, while the EFG values from row 41, Sheet1, are to be copied to row 11 in Sheet2.

In effect, I would like to create a table of this subset of data, in a specific order, from which I could work later.

I can do this manually using “ AutoFilter” to locate the data I need and then write formulas to copy the data from Sheet1 to Sheet2 in the order that I need, but every time the order of the original data on Sheet1 changes I have to start all over.

View 9 Replies View Related

Code That Only Copies Values

Apr 29, 2009

I need to adjust the code below to copy values only. right now it is copying
format as well.

View 2 Replies View Related

Snippet Code For Sum Two Values

Jan 1, 2013

I would like to see a snippet code for adding two simple cells, I would like to write a number in A1 and another in A2 and get the result in A3

View 9 Replies View Related

Code To Count Certain Values

Aug 14, 2007

for code that will test cells e3:g3 in sheet 1 of workbook "AR" for a value of "OK" or "Error". These cells contain If formulas that return "OK" or "Error"

If all Cells = "OK" then I need the macro to put "Ok" in D5 in sheet 1 of workbook "Guide". If 1 or more cells = "Error" then put "Error" in D5.

Also, I know I could use a formula in D5, but I really need the code for my specific application.

View 9 Replies View Related

Copy Certain Value From Row To Another Row When Code Matches?

Jun 20, 2014

I got here different vessel name with corresponding vessel code and a amount. I needed to put the amount the to corresponding vessel if it matches the vessel code. Further explanation are in the attach excel file.

View 9 Replies View Related







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