Eliminating Clutter In Recorded Macro

Oct 26, 2011

I have recorded the following macro and made few changes to it with my little VBA knowledge. But the code still looks very messy.

Code:
Application.ScreenUpdating = False
Sheets("Sheet2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;E:MacrosBSE Indices.iqy", Destination:=Range("A1"))
.Name = "BSE Indices"
.FieldNames = True

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

View 9 Replies


ADVERTISEMENT

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

Shortening Recorded Macro?

Jul 15, 2012

shortening the below recorded macro?

Code:
Sub Macro1()
'
' Macro1 Macro

[Code].....

View 3 Replies View Related

Build Undo In Recorded Macro

Oct 2, 2006

I have recorded certain macros. But after executing macro 'Undo' do not work. How can I do it ?

View 3 Replies View Related

Recorded Macro Missing Paste Commands

Nov 13, 2008

I have been using the "record macro feature". What I want the macro to do is as follows.
1. cut all data from column C and paste it into G.
2. Use the textTocolumns feature to split a comma delimited string into 2 seperate columns.
3. user the textToColumns feature to remove any leading spaces from column G.
4. cut columns d-H and shift them left startign in column C.

I can do all of this find bu using the GUI while recording the macro but when I check the vb script it's completely missing the paste commands.

When I try and run the macro it, quite rightly, returns "run-time error '1004':No data was selected to parse.

Below is the resulting recorded macro.

How do I amend this macro do include pasting the cut data?

View 2 Replies View Related

Inserting A Muliple IF Statement In My Recorded Macro

Sep 21, 2009

I recorded a macro (which worked), then tried to get more out of it by adding code to add a further function (which didn't work). The code is as follows:-

View 3 Replies View Related

Loop Or Repeat Recorded Sort Macro?

Aug 10, 2011

I have a workbook where I need to sort data with range (K2:L24), then move down 208 rows and sort range (K210:L232) and repeat this upto 1000 times. I have shortened a recorded macro as an example and would like to know how to loop or repeat.

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/04/2011 by Greg

[Code].....

View 4 Replies View Related

Recorded Macro - Apply On Pivot Table

Dec 8, 2011

Below is a recorded macro i am trying to apply on a pivot table.

Code:

Range("F4:H4").Select
Range("H4").Activate
Selection.AutoFilter
ActiveSheet.Range("$G$4:$G$100000").AutoFilter Field:=1, Criteria1:="21", Operator:=xlTop10Items

The problem i am facing is that when i am trying to run it is not working.

View 9 Replies View Related

Recorded Macro Incorrectly Hiding Columns

Nov 18, 2013

I've recorded a macro in which I unhide certain columns, copy and paste some information then hide those columns again. The problem is that when the macro is finished, it incorrectly hides columns K to AN. I did not record that and it's not in the code so I'm lost as to why it's happening.

The macro is as follows :

Code:

Sub COPY()
'
' COPY Macro
'
'
Application.ScreenUpdating = False
Columns("K:BT").Select
Selection.EntireColumn.Hidden = False
Range("M5:N24").Select
Selection.COPY

[Code]...

Why it's hiding everything from K to AN. I've tried recording the macro several times but it's just not working, no matter the order in which I hide columns when recording it.

View 5 Replies View Related

Worksheet Function Too Long To Be Recorded In Macro

May 11, 2009

I have a list of items in Sheet1 column A (starting from row 1).

I would like the corresponding column B to have certain values depending on the value in column A (same row), as follows:

If the value in column A has "SYS????CZ", column B should be "HPC"
If the value in column A has "SYSNIS", column B should be "NIS"
If the value in column A has "SYSJBE", column B should be "JBE"
If the value in column A has "ICG????", column B should be "HPC"
If the value in column A has "IL????", column B should be "RUP"
If the value in column A has "SYSHPC08", column B should be "HPC"

What I tried was to record a macro while typing the formula in B1: ...

View 9 Replies View Related

Speed-Up/Optimize Recorded Macro Code

Aug 30, 2006

Im setting up a spreadsheet that does engineering calculations. Im using macros to run sizes from a standard schedule. It basically takes the values from one sheet (schedule) to another (calculation), then the result from the calculation sheet (Value only, not the link) is pasted back into the schedule. The macro seems very bulky and im sure that it can be made more efficient with a loop. here is a sample of the code from the macro;

Sheets("Calc sheet").Select
Range("C6").Select
ActiveCell.FormulaR1C1 = "=Schedule!R[1]C"
Range("C7").Select
ActiveCell.FormulaR1C1 = "=Schedule!RC[1]"
Range("C8").Select
ActiveCell.FormulaR1C1 = "=Schedule!R[-1]C[2]"
Range("C9").Select
Sheets("Schedule").Select
Range("G7").Select..................

View 3 Replies View Related

Recorded Macro Not Including All Rows. 2007

May 30, 2008

I manually create a pivot table (and record my actions) the pivot table references all of the information in my data range (70k+ lines). When I run the recorded macro the new pivot table limits the data range to the first 65536 lines (the old limit)....

View 6 Replies View Related

Recorded Macro Doesn't Seem To Provide Expected Result

Sep 21, 2009

On column A, I simply do an A-Z sort that gives the expected result. So I recorded it as a macro. In column G is a code that corresponds with column A. When the marcro is executed Column A is sorted but the corresponding value in G stays where it is. Clicking the A-Z button works. But when that action is recorded as a macro I get the above quirck. Since VBA is not my beef, I don't really know what wrong.

View 4 Replies View Related

Macro Recorded To Extract Data From Mainframe System?

Oct 12, 2012

I have following macro recorded to extract data from a mainframe system

open "C:DesktopReportRBDRBD.txt" for OUTPUT as #1
rc% = ps.sendstring("{clear}")
rc% = ps.sendstring("a24octdelbom*9w{enter}")
test1 = PS.getdata(450,3,27)
print #1,test1

The requirement here is run the above macro for the next 30 days automatically, for example

rc% = ps.sendstring("{clear}")
rc% = ps.sendstring("a25octdelbom*9w{enter}")
test1 = PS.getdata(450,3,27)
print #1,test1

and so on till 23 Nov. From the start date the macro should run for the next 30 days. Currently i am changing the dates manually in the macro

View 7 Replies View Related

Converting Recorded Macro Into Workable VBA To Add New Sheet At End Of Workbook

Apr 22, 2013

I have a button with a macro assigned. The macro needs to create a new worksheet at the end of the workbook, rename the new sheet to "New County", make the cell size match the rest of the workbook, and then paste in a template from another sheet called "Master".

I recorded a macro that does this, but it has a static reference to the new sheet instead of what ever the new sheet is. So the Macro works one time, but never again. I'm sure this is an easy fix, and perhaps there is a much easier way to do this, but my limited VBA knowledge is hampering me.

Code:

Sub AddNewCounty()
'
' AddNewCounty Macro
' Adds a new County sheet to the workbook.
'
'

[Code]...

View 9 Replies View Related

Excel 2010 :: Result Of Recorded Macro Is Different From Hand Work

Mar 10, 2014

I have csv file with tab delimited fields (see attached blacklist.csv). 3rd and 4th fields are in format dd/mm/yyyy hh24:mi:ss, some fields can be zero. I need to split data to columns and display datetime fields in format dd.mm.yyyy hh:mm:ss.

OK... open csv in Excel, select column A, press button "Split in columns", select tab as delimiter, choose date format (DMY) for 3rd and 4th field and press OK. Test is splitted into columns, now select columns C and D and select desired format "dd.mm.yyyy hh:mm:ss". Then I select columns A:E and set column widths to fit data in columns. This all is OK and without problems (see attached file Handmade.xlsx).

But now... Now I record all previous step into macro. There is macro text: [Code] ....

Now I copy macro text into clipboard and open blacklist.csv again. Insert button to list and bind it to new macro. Paste text of macro from clipboard. (See attached file blacklist_beforeClick.xlsm). Now click button Btn and voila... some dates remain in previous format, some dates seems to be in desired format, but day and month are swapped. Why are there differences when comparing data made by hand and data made by macro??? compare.jpg This is the same behavior in more computers, some use Czech version of Excel 2010, some use English version.

View 2 Replies View Related

Automate Recorded Macro - Sort Range Of Cell Based On Two Values

Jan 23, 2013

I have recorded a macro to sort a range of cell based on two values that is dependent on time in another cell. I now want the macro to run automatically when refreshing the workbook with F9, so as the time changes so will the sorting. Everything works fine except the sorting doesn't refresh when F9 is refreshed.

My recorded macro is:

VB:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, FillCT As Long
For X = 1 To 4
If Cells(Rows.count, 1).End(xlUp).Offset(0, X - 1) <> "" Then FillCT = FillCT + 1

[Code] .....

View 4 Replies View Related

Excel 2010 :: Change Default Pie Chart Colors In Recorded Macro?

Mar 20, 2014

I am working on a project where I am virtually almost finished except for a minor change with the pie chart. I am analyzing some data and recorded a macro to do this and also the pie chart for visualization. However, I do not like the color of the default pie chart colors and would like to customize it. How could I change this within the macro I have recorded?

[Code] .....

View 4 Replies View Related

Looping Recorded Macro - Copy And PastE Information From One Cell To Other Cells

Jul 15, 2014

I've recorded a Marco copying and pasting information from one cell to other cells and some of the copying functions paste to two cells. I just need this to loop through all information I'm copying from the the new cells.

Range("I1").Select
Selection.Copy
Range("D1").Select
ActiveSheet.Paste
Range("J1").Select

[Code]...

View 7 Replies View Related

Excel 2011 :: Mac Recorded Macro Does Not Work With Windows - Runtime Error 1004

Nov 20, 2013

I have been given a macro recorded on a mac and it works fine with Mac Excel 2011. Unfortunately, I need to make it to work on a windows machine, but it comes up with an error message "macro unable to set width property of the window class. Run-time error 1004". When I press debug it takes me to the line .Width = 1456.

Below is the chunk of the code that becomes highlighted when pressing debug.

With ActiveWindow
.Width = 1456
.Height = 795
End With

View 3 Replies View Related

Recorded A Function And Got The Message Box "Invalid Outside Procedure" When I Tried To Run The Macro

Jul 28, 2006

I recorded a function and got the message box "Invalid Outside Procedure" when I tried to run the macro. I don't understand what it means or how to prevent it.

View 2 Replies View Related

Eliminating Leading Space

Dec 6, 2007

Trying to manipulate basketball statistics copied from websites ... each cell has a leading space before the number(s) ... is there any way to globally eliminate the leading space from the cells

Tried find/replace, finding [space] replacing with 0 (which would then be disregarded ... didn't work

Tried converting all cells to number format, didn't work

View 10 Replies View Related

Eliminating The Zeroes From The Calculation

Nov 24, 2006

I wonder if you can help me in this question. I have a MIN function which calculates the smallest value in a list of percentages and then divides each percentage by the smallest in the list. It works fine until one of the percentages becomes zero with the resulting division-by-zero error. Do you think it is possible to make the MIN function to exclude all instances (there may be more than one zero) of zeroes from its calculation? I have attached the spreadsheet.

correct cacluation
130,00%1,20
225,00%1,00
325,00%1,00
445,00%1,80

messy calculation
10,00%#DIV/0!
225,00%#DIV/0!
325,00%#DIV/0!
445,00%#DIV/0!

View 9 Replies View Related

Eliminating Goto Statements

Jun 18, 2008

I have recently been advised to eliminate goto statements. While I have not had any trouble with them so far, it is my understanding that a different structure will speed up my macro, which never hurts. Here I have printed a recent macro I wrote with two goto statements in it heart. Could someone show me how they would rewrite this bit of code while still getting the same results? Here the code compares the active cell value against B and if it does not match, it goes to the next value and compares. If it goes through more than 100 searchs and the term is not found, then it has checked the whole list and needs to stop search, thus the progression of C. A few options are offered before closing down the macro, but ultimtaly, C needs to get to 100 to exit the sub. Thus the goto Alpha that repeats the addition to C.

Alpha:
If ActiveCell.Value CStr(B) Then
ActiveCell.Offset(1, 0).Select
If ActiveCell.Value = "" Then GoTo Beta
C = C + 1
If C = 100 Then
I = MsgBox("Complete. Do you want to continue with Received data?", vbYesNo)
If I = vbYes Then
Windows(D).Close
Call ReceivedDataUpdate
GoTo Epsilon
End If

View 9 Replies View Related

Eliminating Blank Rows

Aug 2, 2008

I have 5 columns and 1000 rows of data,
All cells has formulas, resulting blank or value,
I need a formula to copy only the rows with values
building another column (list) with no blank cells
Is it possible without macro?

View 9 Replies View Related

Eliminating Data With Export To CSV

Dec 2, 2008

I have a 23 worksheet workbook that I am exporting to csv files. Somehow the data (formulas) appear to be included in the export, even though when I click on a cell in the csv file it does not show the formula. I do not want the data to be exported. Any suggestions on how to modify my macro so that only the values of the cells without the data get exported? Here's the macro:

Sub SaveAllSheets2CSV()
Dim wsSheet As Worksheet
With ActiveWorkbook
For Each wsSheet In .Worksheets
wsSheet.SaveAs Filename:=.Path & "" & wsSheet.Name, FileFormat:=xlCSV
AddtoMRU = False
Next wsSheet
End With
End Sub

View 9 Replies View Related

Eliminating Spaces In Formula Value

Nov 20, 2009

I am having trouble with eliminating spaces from the value I've generated from my formula.

The formula will take the first 4 characters from a list of names, and add to that a number and a year. (For instance: "Conniff" would become "conn_01_09").

My problem is if I have "Ag Services". "ag s_01_09" would be generated. How can I eliminate that space? The list of names is in one field.

The formula I used so far is: =CONCATENATE(MID(E2,1,4),"_",MID(F2,1,2),"_",MID(C2,3,2))

I tried TRIM and CLEAN, but couldn't get them to work right.

View 9 Replies View Related

Eliminating Empty Cell In Concatenate

Aug 6, 2014

Eliminating empty cell in the concatenate. I am concatenating many cell together. Example is Column A has a word " Starter" Column B is the type of tractor it fits " Case" Column C thru E have other names IE John Deere, Ford only if the part fits more than one type of tractor. In my final Concatenate i end up with many comma's and nothing follows. I have placed a ", " in between each reference of the cell. If the cell is 0 or null. I want the concatenate to ignore the cell and extra commas.

My current function reads + Concatenate(A1,", For ",B2,", ",C2,", ",D2,", ",E2)

What I have now.
Starter, For John Deere, , , , , , , .
Starter, For John Deere, Ford, , , , , , .

What I wish is.
Starter, For John Deere, Ford.

View 2 Replies View Related

Eliminating Spaces Within Text Cells

Jan 8, 2010

I have a formula that is dependent upon a column of cells containing text. Cells within this column randomly have an additional space (" ") following the words. With this invisible space, the formula doesn't work as intended.

Since I have an extremely long list of names, is there a way to easily remove additional spaces after words without manually going through each cell and deleting them?

View 9 Replies View Related

Aggregating And Then Eliminating Duplicates From A Database

Feb 3, 2009

I want to do is create a template that can be used for generating an attendance sheet with corresponding statistics on a semester by semester basis.

I've attached the workbook im using. For the purposes of my query only columns B-F are relevant. What i want is a formula that can compile all the names and information in columns b-f on a seperate sheet (sheet1)

I want to make sure that duplicates are eliminated from my final list so that even if a name appears multiple times in the sheets titled sessions 1-5 it only appears once in sheet1.

I want to do this in a formula so that it can be used over and over again. If possible I would also like the formula to exclude blank rows in columns b-f in the final list.

View 4 Replies View Related







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