Shorten Code: Clean This Up?

Mar 30, 2007

I am trying to run the following

ChDir _
"C:Documents and SettingsChrisDesktopRainforestMASTER LABORNew Master Labor"
Workbooks.Open Filename:= _
"C:Documents and SettingsChrisDesktopRainforestMASTER LABORNew Master Labor2 Tuesday.xls" _
, UpdateLinks:=0
Workbooks.Open Filename:= _
"C:Documents and SettingsChrisDesktopRainforestMASTER LABORNew Master Labor3 Wednesday.xls" _
, UpdateLinks:=0
Workbooks.Open Filename:= _
"C:Documents and SettingsChrisDesktopRainforestMASTER LABORNew Master Labor4 Thursday.xls" _
, UpdateLinks:=0
Workbooks.Open Filename:= _
"C:Documents and SettingsChrisDesktopRainforestMASTER LABORNew Master Labor5 Friday.xls" _
, UpdateLinks:=0...................

It worked for a short time but now I am having problems running it. I get an excel error that says excel can't continue. Someone said in a previous post that this could be cleaned up and consolidated. how to clean this up. It took me forever to get this right.

View 6 Replies


ADVERTISEMENT

Shorten Vba Code

Jun 26, 2007

it counts data in columns 4 to Endxlright and then creates a graph based on the status. I'm sure there is redundant code in there but can't seem to shorten it myself.

Option Explicit
Dim vEndCol, vTotal, nFail, nOth, vRow, vCol, nExc, nSum, n, x
Dim Mth As Integer
Dim Cell As Range
Dim vMth, vstMth, vstart, nOK, xRow, vStatus, wks, Chart

Private Sub Calcs()
Sheets("Report").Activate
'Clear previous data and formats
Range(Cells(2, 2), Cells(51, 30)).ClearContents
Range(Cells(2, 2), Cells(51, 30)).ClearFormats
Sheet1.Activate
'Identify last row of data
Range("IV8").End(xlToLeft).Select
vEndCol = ActiveCell.Column
'variables for all data...................

View 5 Replies View Related

Shorten Code Typing Methods

Aug 11, 2007

Instead of typing out my code hundreds of times, I would like to replace it with an abbreviation or variable(?). Here is my example. If I have this in the wrong place please let me know. I want to replace Activecell.Interior.Colorindex with ACIC. I tried to Dim ACIC as range, variant, string...to no avail. In combination I Set ACIC = Activecell.Interior.Colorindex and that didn't work. I have been toiling with VBA for a year and I am still trying to learn the terminology and understand it so please forgive me if I seem really NOOBIE. :-)

View 9 Replies View Related

Easier Way To Shorten Up Part Of Code That Is Repetitive With Array

Jun 3, 2013

I have a macro that works but was wondering if there is an easier way to shorten up the part of the code that is very repetitive with an array or ? Nothing I have tried works except the code below.

Code:
Sub ClearAndReset()
Dim WS1 As Worksheet
Set WS1 = ActiveWorkbook.Worksheets("Stocks")
WS1.Unprotect
Application.EnableEvents = False
With WS1

[code]....

View 3 Replies View Related

Clean Up A Code For Formatting A Column

Feb 4, 2009

I have this code, which is primarily built by the record macro utility. I know that record macro does some unnecessary steps such as selecting while inserting columns etc which is generally never done in vba.

View 5 Replies View Related

Clean Up Pivot Table Code

Feb 19, 2013

Someone sent me a spreadsheet and asked me to clean up the code, which has been going pretty well, but they had this bit of code that is unfamliar to me and is quite bulky, I was wondering if there is a cleaner way to write this bit of code? This is only a very small portion of this particular code that they had in the workbook, so I would like to make it look a bit neater if at all possible.

Code:
ActiveSheet.PivotTables("PivotTable3").PivotFields("Annuity Type").Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet.PivotTables("PivotTable3").PivotFields("Category").Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet.PivotTables("PivotTable3").PivotFields("Product Series").Subtotals _
= Array(False, False, False, False, False, False, False, False, False, False, False, False _

[Code] ..........

View 2 Replies View Related

Vba Code To Extract And Clean Data Based On A Set String Ending

Dec 5, 2013

I would like to extract competition naps from the competition entries and then remove the string ending "nap" from the data so it can be pasted to another sheet in it's 'clean' format.

on the example sheet column B will always be the first column and the range will extend to either G,H or I (always the max range as there are always 6 to 8 races)

i would like the code to search through these columns of data and find the cell ending in 'nap' then to return this in column i, once done remove 'nap' ending from both the source cell and column i.

once done to then go through all the rows and do similar

the end result would be all naps returned into cell j and all the 'nap' endings through the data range B to I (max) to be removed to leave the horses name only.

in book 3 the first row nap was sommersturm so i have shown the outcome i would like with the nap ending in I1 removed and the horse name returned in J1 again minus 'nap' ending.

the data will always be clean with no leading/trailing/excessive spaces and always be lower case too. sometimes a space is not in between horse name and nap but it's always last 3 characters i want removed still.

View 4 Replies View Related

To Shorten An If Formula

Jul 28, 2008

My formula is:

=IF(E4="Break",D4,IF(H4="Break",G4,IF(K4="Break",J4,IF(N4="Break",M4,IF(Q4="Break",P4,0)))))

My problem is that excel only lets me use 7 IF functions and I need a total of 12. So I need a different way to perform that same function.

View 13 Replies View Related

How To Shorten Conditional String Construction

Feb 10, 2014

I'm developing a spreadsheet that is generating relatively simple source code. As far as excel is concerned, based on columns of data in the first sheet, generate other sheets - conceptually straightforward, but the formulas are getting stupid long. For example, suppose I have 4 columns:

Needs A, Needs B, Needs C, and Needs D.

If there is a "Y" in any of these columns, I need to generate corresponding text that is concatenated together:

=if(a1=="Y") use "Field1[if1]"
=if(b1=="Y") use "Field2[if2]"
=if(c1=="Y") use "Field3[if3]"
=if(d1=="Y") use "Field4[if4]"

The result in some other column could be (samples):

Field1[if1]
Field1[if1].Field2[if2]
Field3[if3]
Field2[if2].Field4[if4]

a couple of notes:

- you can have field 2 without field 1, etc.

- if there is a trailing field, then I need a period separating the two.

Needing this separating period between some of the columns is driving me bat crap crazy. My approach to this point is to build work sheets that feed the main page, thus isolating the logic complexity. This seems to be the only way to segment the processing into something one can edit.

View 3 Replies View Related

Shorten Cell's Content When Specific Conditions Are Met?

Feb 1, 2013

I have need of VBA code that will check collumn D, starting at cell 7 until cell 206, for when data that is entered starts with 100. When this occurs it will remove all of the data in that same cell except for the last 12 digits.

Here's an example.

When using our barcode scanner to capture a FedEx Tracking number the barcode captures the following:

1001853514360009020200802541997796.

Embedded in that long string of numbers (which are formatted as Text) is the tracking number. Specifically the last 12 numbers are the tracking number. However, FedEx varies this code at times so the last 12 numbers are the tracking number only with the raw data captured by the scanner starts with 100. Until I find additional conditions this VBA code will have to ignore all of data that is captured in collumn D starting at cell 7 until 206.

View 3 Replies View Related

Formula To Shorten An Alphanumeric Line Of Text

Jan 25, 2010

I'm using the formula '=LEFT(A2,4)+0 to shorten a numbered line of text.Is there a way to adopt that formula to do the same thing to an alphanumeric line of text (i.e. 80A0267AA1 to read 80A0267) or even better substitute a "-" in place of the "A" (i.e. 80A0267AA1 to read 80-0267)? I know this is really picky, but I figure it's worth a shot.

View 10 Replies View Related

Shorten String And Convert To Upper Case?

Mar 7, 2013

I got a list of counties in Texas, but the list is in mixed case and always has a " County" after each one. I got it converting to upper case, and have tried removing the " County" but no luck. Below is the code I have:

Code:
Sub TEXAS()
For a = 1 To 254
R = "D" & a
i = "a" & a
ActiveSheet.Range(R) = UCase(ActiveSheet.Range(i))
Next a
End Sub

View 7 Replies View Related

Shorten This Query: If The Cell Doesnt Contain Any Info Dont Update

Apr 9, 2007

i have some code (see below). at the part where it says

If ActiveCell. Offset(0, 9).Value <> "" Then
.Fields("Skill_32") = ActiveCell.Offset(0, 9).Value

i want to make this smaller - i have to write this line bout 60 times 3 times over (incresing the numbers as i go ((0, 9..10..11 etc etc and (Skill_32..33..34 etc etc) )) to give you an idea of what im trying to accomplish - im opening and writing to a database but if the cell doesnt contain any info dont update.

Function EditCPS(ByVal StaffNumber As Long)
On Error Goto Err_Handler
Dim SkillsBuilderDB As Database
Dim RSSkillsBuilder As Recordset
Dim MySQL As String
Set SkillsBuilderDB = OpenDatabase(Worksheets("Adding Data").Range("IV1")) ' database location
MySQL = "select * from CPS where StaffNumber=" & StaffNumber
Set RSSkillsBuilder = SkillsBuilderDB.OpenRecordset(MySQL)
With RSSkillsBuilder
.Edit
If ActiveCell.Offset(0, 9).Value <> "" Then
.Fields("Skill_32") = ActiveCell.Offset(0, 9).Value
Else............................................

View 7 Replies View Related

VBA To Clean Data Set

Jul 7, 2009

Sheet1

A1Bad Data2Bad Data3Bad Data4Bad Data5Bad Data6Bad Data7Bad Data8Bad Data9Bad Data10Bad Data11Title12Good Data13Good Data14Good Data15Good Data16Good Data17Good Data18Good Data19Good Data20Good Data21Good Data22 23Bad Data24Bad Data25Bad Data26Bad Data27Bad Data28Bad Data29Bad Data30Bad Data31Bad Data32Bad Data33Bad Data34Bad Data35Bad Data

Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4

How can I ensure that all Rows before "Title" and all Rows after the last populated Row (denoted by the fact that there is a single blank Cell after it) are completely deleted?

View 9 Replies View Related

Cell Clean Up Using VBA

Apr 28, 2006

I have a spreadsheet that has data in columns A through AE. I have built a VBA that deletes all columns except 2 (columns C & AF), and brings them over to columns A & B.

Column C contains a 10 digit number and column AF contains text similiar to "ASSIGNED ON 10 CALLS BOLDI". My VBA deletes all unneeded columns, but I am having trouble getting it to do 2 additional functions. I want it to delete the verbiage of "Assigned ON" in the cells under column AF, and delete the last number of the account number under column C, so that the account number is only 9 digits long.
Here is my VBA:

View 9 Replies View Related

Clean Up Recorded Macro?

Jun 1, 2014

I want to clean up this recorded macro but not sure how, it highlights duplicate values in a column

[Code].....

View 3 Replies View Related

SQL And VBA Memory Usage And Clean Up

Feb 3, 2010

I have created an excel tool w/ A LOT of macros in it, and the tool "speaks" to the SQL server (downloads data from it and uploads it back). My big problem now is that every time I run any of the VBA code the amount of RAM that is getting allocated to Excel (2007) is increasing - I am checking it in the Task Manager. So if I work for a long time without closing down Excel - my entire RAM is getting consumed and the system slows down, and sometimes crushes.

I was wondering if there is a way in VBA to clean up memory that is used by Excel.

Do you have any hints? I am using extensively 3 things - screenupdating off; displaymessages off, and calculations off. But this speeds up Excel but doesn't reduce the memory usage.

View 7 Replies View Related

'trim' Or 'clean' Spaces

Feb 5, 2010

On a regular basis I have to upload cost to our order system. These cost are sent to me by the suppliers, and the part numbers have to match exactly, (from the excel sheet to the order system), or else the cost won't upload.

I have found that in some of my upload files there is a space, or sometimes several spaces, at the end of the part number. These spaces will screw up the upload. I alwyas use the "Replace" option to replace spaces with nothing, and that usually works.

In the attached sample file, there are 3 part numbers with a space at the end of the part number. I tried using the replace option. That didn't work. I also tried using the =TRIM() formula and the =CLEAN() formula, and neither of those removed the spaces. Why can't I remove the spaces from the end of these part numbers?

View 4 Replies View Related

How To Clean Empty Cells

Sep 11, 2012

I have a bunch of "empty" cells. They only look empty visually. In fact, they contain something, because they are preventing some formulas from working. How do I cleanse them and make them truly empty without disturbing the contents of the other cells containing real data.

View 1 Replies View Related

Clean Up Multiple Vlookup

Mar 6, 2014

I am trying to clean this formula up. I cannot figure out if it I am supposed to use index, sumif, sumifs, vlookup, etc.

(IFERROR(VLOOKUP("100",'Total'!$9:$30,4,),0)+IFERROR(VLOOKUP("101",'Total'!$9:$30,4,),0)+IFERROR(VLOOKUP("101.1",
'Total'!$9:$30,4,),0)+IFERROR(VLOOKUP("102",'Total'!$9:$30,4,),0)+IFERROR(VLOOKUP("102.1",'Total'!$9:$30,4,),0))/1000

This formula does what I need it to do, but this is the shortest of the lines. Another cell has the same structured formula, but 15 hard keyed values. I know there is a way to clean this up, I just can't remember how and searching isn't providing the results I need.

View 9 Replies View Related

Clean Up A Template That Shows #DIV/0

Jan 10, 2009

Excel 2007

I am trying to clean up a template that shows #DIV/0! in the cells that contain the formula below, when there is no value present in the NamedReference.

=SUM((B6/1024)/NamedReference)

View 9 Replies View Related

Using VBA To Clean Up Imported Data

Mar 17, 2009

Using VBA to clean up imported data ...

View 9 Replies View Related

TRIM Or CLEAN Numbers

Jul 5, 2006

I'm trying to remove leading spaces in cells that have numbers. I'm familiar with the functions TRIM and CLEAN but they don't seem to work on numbers. Unfortunately, just reformatting the cell as text doesn't work.

View 9 Replies View Related

Clean & Trim Function In VBA

Aug 21, 2006

"clean" function is not recognized.

Sub ConvertToTrim()
For Each rng In Selection
rng.Value = Clean(Trim(rng.Value))
Next rng
End Sub

View 2 Replies View Related

Clean Same Lines And Text To Columns

Sep 24, 2013

I need to do in excel, clean same lines and text to columns.

In the 1fs sheet "Sheet1" is the file I need to clean same lines and text to columns;
In the 2sd sheet "final" is the result I need in the end of the clean lines and text to columns;

View 6 Replies View Related

Emailing Clean Data From Excel?

Jun 25, 2013

I am building a weekly email to my clients giving them some data on their account. When i send through file-> Share as html email, the formatting gets all screwy.

View 2 Replies View Related

Clean Up Data In Contact Sheets?

Dec 2, 2013

I am putting together a master sheet of 1000s of contacts for colleagues taken from various sources (outlook contact download, linked in download, inputted business cards etc). I have noticed that everyone has their own way of using outlook and the data (normally addresses and phone numbers) appear in different columns and formats. I have used the function concatenate to add zeros back to numbers if i have had to use .csv as the download output, but I have the issue of mobile numbers in the wrong columns (i.e. someone has put a mobile number as the business phone). Is there a way of creating a new column and then applying a logic formula of some kind saying if a number starts with 07 then it appears in the new column, but if it doesnt then to ignore it therefore separating the mobile numbers so I can add to the correct column?

View 1 Replies View Related

How To Remove Duplicates And Clean Up Contents

Jun 10, 2014

in my sample xls,there are some contents (text) that i don't need. i'd like to remove the duplicate entries from the Consignee Address rows based on the contents of the Consignee City cells. what i mean? lets say, here,the word CHIOS shows 3 times,we dont need that,so we have to delete it in the Consignee Address,and leave it only in the Consignee City

Shipment Number Consignee Consignee Address Consignee ZipCode Consignee City Consignee PhonePieces Shipment Total Weight
0866-03636276 MRS NELLH NIRI LEAFOROS AIGAIIOU 22 CHIOS CHIOS 82100 CHIOS302023288 1 0.11

so,the final text should be like this:
Shipment Number Consignee Consignee AddressConsignee ZipCode Consignee City Consignee PhonePieces Shipment Total Weight
0866-03636276 MRS NELLH NIRI LEAFOROS AIGAIIOU 22 82100 CHIOS302023288 1 0.11

in the second case,we have something like this:
Shipment Number Consignee Consignee Address Consignee ZipCode Consignee City Consignee PhonePieces Shipment Total Weight
0866-03636453MRS KRISTINA L. KALIVION 252 LAMIA -- SELECT STATE -- GR 35100 -- SELECT STATE -- 6954689 1 0.43

here,we want to move the city (LAMIA) ,and replace the -- SELECT STATE -- in the to Consignee City

check the demo file,to see exactly what we need.. DEMO.xlsx

View 4 Replies View Related

Function To Clean Up Date/timestamp

Jun 8, 2009

I have date/time data in the following form:

Mon Jan 12 07:26:26 EST 2009

I have tried multiple forms of LEFT, RIGHT, MID, etc. Date & Month are always three characters, but the date ("12" in this example) can vary between 1 or 2 characters.

View 8 Replies View Related

Clean And Copy Data From One Worksheet To Another?

Jun 23, 2012

I need to clear the worksheet named 'ZWM0104' then have to eliminate the lines 1, 3, 5 and the columns 'A' and 'C' of the worksheet named 'Cobaia_ZWM0104' done that need to copy all cells with data from the spreadsheet called 'Cobaia_ZWM0104' to the worksheet named 'ZWM0104'

i'm try...

Code:
Sub teste()
Application.ScreenUpdating = 0
Worksheets("ZWM0104").Range("A:N").Delete
Worksheets("Cobaia_ZWM0104").Select

[Code].....

View 7 Replies View Related







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