Smart Range Selection In Macro

May 22, 2013

Im having some problems with range selection in macros. Basically, what the macro does is Copy / Paste as Values in differet sectors of an active worksheet, so this is the code for each range of cells that I need to copy paste:

Code:

ActiveSheet.Range("C14:E15").Select
Selection.Copy
ActiveSheet.Range("C14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

The problem with this code, is that because it specifies EXACTLY which range to select, if I add a row before that range the macro will be now selecting an incorrect range.

For example, say I have a value on cell A5, and the macro is set up to copy/paste that cell. Later on, I decide to add a row in A3, so the value I would need to copy/paste will now be in A6, but the macro will still execute on A5 (incorrect, as it should now execute in A6, and that is what I have to manually correct each time).

View 3 Replies


ADVERTISEMENT

Macro To Run On A Dynamic Selection Range

Oct 13, 2008

I am looking to run a marco for a selection range, and the selection range could vary in size.
Using the Macro recorded (whilst turning on the relative reference) the Macro runs for a defined number of cells. I would like to run certain Macro, for different ranges of cells.

View 9 Replies View Related

Merge Data (smart) From One Sheet To Another?

Mar 18, 2014

So I have two worksheets. One sheet has all of the names of attendees to a current event (column a, about 109 entries), and the other sheet has all of the names that have ever registered for my events along with their emails (column a and column b, 3000 entries). I need to merge data from column B of the second sheet to the corresponding name in the first worksheet, and disregard the extras (or just put them at the end so i can clear the contents). So I am just trying to get the email addresses of the people in the first sheet, from the data in the second sheet.

I've tried to look at the consolidate data function, but that does not match up the names to the email addresses correctly. What about a filter?

View 2 Replies View Related

Creating Smart Dropdown List

Apr 6, 2011

I have a drop down list in excel. What do I need to do so that it will automatically take me to the closest/best label on the list when I type just a few first letters?

View 14 Replies View Related

Smart Generation Of Coordinates For Excel Shapes VBA

Sep 5, 2013

I'm using Excel to create a flowchart from a configuration sheet. I'm not manually entering the coordinates. Instead, I draw the start step in a set location. The next step(s) that's connected to the first step is placed directly below the start step. if there's more than one step connected to the start step, it's placed at the same y-coordinate but shifted along the x-axis.

The problem I'm running into here is this: say I have three steps connected to the start step and three further steps connected to the first of the three connected to the start step, how can I keep track of this and shift the other two steps connected to the start step along the x-axis so they're not positioned above the four steps below the first step (and as such, in the same location as other steps)? I'm not sure if my description is particularly clear or not so I've attached a drawing that will hopefully clear things up.

Is there any way of giving Excel shapes a "weight" so that other shapes won't line up on top of them?

View 3 Replies View Related

Event OnClick - Show Smart Art Shapes Below (child)

Oct 10, 2012

I'm trying to make a menu in my Workbook to access all the others sheets.

To make things easier for my boss, I'm trying to make the menu with SmartArt Shapes (Hierarchic) because it's easier to add/remove itens.

The thing is: he wants it to show the boxes below (hierarchic child) when i click the "mother" box.

It will work pretty like web menus except the mouseover. Image below

menu.jpg

View 1 Replies View Related

Finding Smart Coding Userform Textbox Values To Sheet

Mar 21, 2012

In my userform I have a lot of textboxes. When the user clicks "OK" the values of these textboxes are transfered to row 3 of sheet1.

For this I use some of the code below:

Code:
If NaamTextBox.Value = "" Then ActiveCell.FormulaR1C1 = " " Else: ActiveCell.FormulaR1C1 = NaamTextBox.Value
ActiveCell.Offset(0, 2).Range("A1").Select
If GroepComboBox.Value = "" Then ActiveCell.FormulaR1C1 = "" Else: ActiveCell.FormulaR1C1 = GroepComboBox.Value
ActiveCell.Offset(0, 1).Range("A1").Select
If TypeTextBox.Value = "" Then ActiveCell.FormulaR1C1 = " " Else: ActiveCell.FormulaR1C1 = TypeTextBox.Value
ActiveCell.Offset(0, 3).Range("A1").Select
If TypecodeTextBox.Value = "" Then ActiveCell.FormulaR1C1 = " " Else: ActiveCell.FormulaR1C1 = TypecodeTextBox.Value

This goes on for about 55 columns. Also, not every column is used as you can see in de code above.

It seems to me that this is not smart coding, so my question is: can you make this more efficient?

I did find some nice code with uses EmptyRow (find first empty row) but in my case it's always row 3 where de input is placed. After this row follows much more data.

View 5 Replies View Related

Smart Filter To Only Show Contract Items That Had Major Impact On Gross Profit

Mar 10, 2014

seeattached data set.

Contract Item
Gross Profit
GP %

[Code]....

It is Gross Profit in Dollars and % for a particular project. Each row is a contract Item. The Overall Gross Profit for the month in dollars is 34,114.86 In preparing a short commentary to discuss this 34,114.86 I need to discuss atleast some contract items. If there were no negative results I have often in the past simply written. The top 5contributors to this Gross Profit were contract items 1 -6, out of 42, delivering 80% of the result. I might also go into what actually those contract items were and why they presented such a decent Gross Margin, ie. Costs came in well under budget(estimate). But with negative results, the bottom 4 contract items represent a large dollar loss of-34k which is 100% basically of the Gross Profit itself. If these had even just broken even we would have a GP double the current amount. So they obviously deserve as much comment.

Q1
In excel orsimilarly in say Crystal Reports what is a good way of further sorting these 42records either in a table or chart, whereby say the top 80% contract items that had a major impact on the gross profit are shown and the rest hidden. Ie. All thelittle sub 1000 or sub -1000 amounts.

Q2
How wouldother people here write a commentary on this data set? Can you script something to illustrate?

View 3 Replies View Related

About Range Selection

Jul 22, 2009

A question regarding "AboutRangeSelection" procedure on Chapter 11 in the **, Excel 2003 Power Programming with VBA by John Walkenbach.

View 3 Replies View Related

"smart" Copy Paste

Dec 8, 2008

i need a VBA string that will be able to copy and paste values but can self adjust, let me rephrase that:

i get some raw data from another application and need to paste it on to excel and lets say that that data fills up cells A1 trough H200

HOWEVER this data ALWAYS varies in row length like it could be A1 trough H500 and so on,

when i try to record a macro to do this it will by default go and paste tha new data where the original macro was recorded say a1 trough h200, but i need the macro to acknowledge the fact that that row is not empty and should paste the data on the next available row,

in the end what i need is for this data that varies in length to copy and paste its self right below it to obtain the same data 10 times,

say row a1 has "Jack" and row a2 has "stacy" i should have Jack and stacy 10 times down

Jack
Stacy
Jack
Stacy
Jack
Stacy
Jack

etc...

View 9 Replies View Related

Deriving Range From A Selection

Jan 20, 2010

I am trying to figure out how to derive a range from a selection. Here is the code i am using to select the table.

View 5 Replies View Related

Range Selection With Variable

Jan 27, 2010

I am using Selection.ClearContents command to clear data from column F and G. I know the last row as 230 but the starting row is the first empty cell which I find using Do While loop in range F31 to F230. The variable that stores the first empty cell number is 'r'.

Range("F &r:G230").Select
Selection.ClearContents

View 3 Replies View Related

Dynamic Range Selection

Feb 8, 2010

I am filtering a list in Column H and depending on what criteria I filter on I need to be able to select only what I have actually filtered for. I am using the code below to find the lower right corner of my range that I'm trying to select and this works great.

View 3 Replies View Related

If Range Selection Does Not Match Value Then

Mar 7, 2012

VBA IF statement that references the below code. the IF statement would say if the below selection does NOT match 'putname' then

Code:
Range(Selection, Selection.End(xlDown)).Select

View 2 Replies View Related

Cell Selection Over Given Range

Apr 8, 2014

I'm looking to go to every 8th cell in a column when I hit the enter key. I was thinking of selecting a small range say from A2 which is zero to A10 which would also be zero then A18 which is zero. The reason being I have a lot of figures to put in to each zero cell then I select "Series" to fill the cells in-between with the incremental figures between the two zeros which would be the difference between the two zero figures.

View 2 Replies View Related

If Statement With A Range Selection

Aug 9, 2007

I was making a simple spreadsheet as I'm taking practice tests for some IT certifications and the spreadsheet I was making was to chart out my progress.

I had a range of scores in some cells and one of the formulas I used so that I didnt have errors in the sheet like div/0 went like the following:

=if(b5:b50="","",sum(b5:b50)) this seemed to work really well for the one section, however I tried to get a little fancy as always and I think I messed something up. Beneath that I tried to separate each practice test with the same sort of formula resulting something like the following:

=if(b30:b40="","",sum(b30:b40)) this however just returned an error #value. I dont understand why the first formula worked and the second didnt. Then again, I'm not really an excel guru, back in college I was really good with it but I dont really remember much.

View 9 Replies View Related

Range Selection Query

Feb 27, 2009

I'm writing a couple of macros which require selection of a range. The user could either select the range before executing the macro or if range has not been pre-selected, an inputbox should pop-up through which the user can select required range.

View 9 Replies View Related

Chart With X-Axis Range Selection

Feb 26, 2014

I have excel file and need to create a chart with X axis to be scalable, by selecting (from drop down menu) - start and end dates.

View 3 Replies View Related

Range Selection And Origination Difficulty

Nov 3, 2008

I may not have the terminology right, but here's my problem:

With the Range Select Formula i.e.

View 14 Replies View Related

Selection Of Range For The 'slope' Function

Dec 20, 2008

Here is what I'm trying to do:

1) I have column labels, and row labels on one worksheet which I input into
a function.

2) These inputs should be matched with column and row labels, and then input
into the index function to get a certain cell - let's call it the event cell.

I'm ok with this part. Then:

3) I would like to collect a one column array. The number of cells in this
array should depend on an input from a cell in the worksheet, and the final
cell in the array should be the column label of the column where I am
inputing the formula.

4) The array from 3) should go into the slope function.

5) Then I want to get the second array for the slope function from a fixed
column, but the same rows as in the variable first array, and this should
input into the function.

View 13 Replies View Related

Move Range Selection By Two Columns

Nov 19, 2009

I have a spreadsheet with data organized into columns in sets of two - the first column is an X value (Pixel number) and the second column is the Y value (pixel density). I'm trying to make a macro that will select the first set of columns, chart it, move the chart to the next sheet, then select the next two columns of data, chart them and move the chart to the next sheet etc. I've gotten as far as having it make the chart and move it, but I can't seem to make it select the next set of columns - I've been trying different things for a couple days now.
Code:

View 4 Replies View Related

Range With (Center Across Selection) Cells In It

Jan 30, 2012

I am trying to use Range.Find in a named range that has some areas where two cells are merged using the format "Center Across Selection"

Set rngTemp = wbMaster.Range("PnLDateRow").Find(what:=dDate)

I get a run time error 438 "Object doesn't support this property or method"

Is it not possible to use this method to find the cell in this range? I tried iterating through the range but that errors also.

View 1 Replies View Related

VBA For Selecting A Range To Fill A Selection?

Aug 27, 2012

I have to run reports every week where I show the number of days items are pending some sort of action. I use an autofill action in a macro but the number of rows changes every week. Here is the current section of my macro that I use. I just input a row number that I know will not exceed the number of rows required by my data (12900). What can I replace this with (Selection.AutoFill Destination:=Range("J2:J12900") so it will only fill the number of rows current filled in in either row I or K?

Range("J2").Select ActiveCell.FormulaR1C1 = "=R1C19-RC[-1]" Selection.AutoFill Destination:=Range("J2:J12900") Range("J1").Select Selection.Copy Columns("J:J").Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=FalseApplication.CutCopyMode = False

I have a date in cell s1 that I subtract from the date in row "I". I then copy the result of row J and paste it as values.

View 6 Replies View Related

Deleting Particular Sheet / Range Or Selection

Oct 2, 2012

Any easy way of finding out if deleting a particular sheet / range or selection will mess up any references elsewhere in the workbook?

View 1 Replies View Related

Delete Row Based On Range Selection

Oct 14, 2008

Here is my
ThisWorkbook.sheets("sheet1").Range("M").Select
For Each cell In Selection
If cell.Value = ThisWorkbook.Sheets("Sheet2").Range("A").Value Then
cell.EntireRow.Delete
End If
Next cell
Range("a1").Select
End Sub

I want to remove all rows in sheet 1 that contain any value found in Sheet2 A I using XL 2003.

View 9 Replies View Related

Change Range Selection With A Variable

Feb 19, 2009

How do I change the selection of a range with a variable, and not a hardcoded number in XL2003? I have to update a set of spreadsheets every month, and it's a hassle to have to constantly open my pivot table worksheet, copy, open the summary worksheet, paste ... etc. etc. etc. The code below is my attempt at creating a ComboBox with "January, February, March, etc." and every time I select a particular month it will automatically copy data from my pivot table worksheet into my new summary worksheet in the correct column. The range of data from my pivot table worksheet will never change, so I have no problem hardcoding that in, but based on which month is selected will alter which column the data goes in in the new worksheet.

I want to be able to write code for one month (say January) and then when I want to use a different month (say February) I can just change the column number and call up the originial January code.

Private Sub ComboBox1_Change()
Dim ColNum ' This is the variable I want to change based on which month is called
If ComboBox1.Value = "January" Then
ColNum = 1 ' Column number for Column A- Where my January column is
Elseif ComboBox1.Value = "February" Then
ColNum = 2 ' Column number for Column B- Where my February column is
' etc. etc. for each month
End If
Call January
End Sub

Private Sub January()
' Just a quick msgbox to make sure the previous macro is calling this one
MsgBox "Is this macro running?", vbQuestion + vbYesNo, "Check"...........................

View 9 Replies View Related

Dynamic Range Selection For Charting

May 7, 2009

I have three rows that each attempt to pull in data from a range on different worksheets. All but one return nothing but "#N/A" values. The one row returns values from the proper range. (User selections determine which row will have data).

Second, I successfully pull data from the row containing actual information into another row, using the following formula: "=OFFSET(E$36,CHOOSE($Y$1,0,1,2),0)" on a cell-to-cell basis. The value in $Y$1 chooses the row to look at, based upon a dropdown selected on another worksheet.

So I now have a row with =OFFSET(E$36,CHOOSE($Y$1,0,1,2),0),=OFFSET(F$36,CHOOSE($Y$1,0,1,2),0),=OFFSET(G$36,CHOOSE($Y$1,0,1,2),0) and so forth. I can find the last value in the row, but I cannot find a way to extract the address from that, and create a table that will use as a series the last 26 values in the row.

For reference, I use "=LOOKUP(9.99999999999999E+307,E49:FD49)" to determine the last cell with a value (gleaned from a Dueling Excel Youtube Video, - very helpful!).

I hope the above will be clear enough, but if not, I'll be happy to provide additional information / clarification.

View 9 Replies View Related

VBA Dynamic Range Selection Failure

Aug 3, 2009

I have a log that I use to keep track of my hours where the days hours and charge numbers get summed and moved to a new sheet via a command button. One of the categories is week ending date. I want the week ending date cells to merge if they match and cannot get the range I want to highlight. I can move the data, find and define the first and last cells in the range, but can't get the range.select command to work. I think it is just a syntax error, as I am new to VBA.

I can open a Locals window and watch it assign values to myFirstCell and myLastCell of "$A$36" and "$A$44" respectively, but I get an error on either the set range= or range.select lines.

My code is as follows:

Private Sub Post_Hours_To_Log_Click()
'Posts the day's hours to the hours tracker.

Dim myFirstCell, myLastCell As Variant

Dim myRange As Variant

***Removed N/A code that goes to another sheet and decides which data to copy***
Application.Goto reference:=Worksheets("Hours Log").Range("A2"), _
Scroll:=False

View 9 Replies View Related

Prevent Shape & Range Selection

Dec 7, 2006

I have put a 3d shape on the excel sheet, and would like it unclickable. Is there way to accomplish that with the sheet still clickable. I know that you can use protection from Tools manual to protect the sheet. Is there way to protect just specific object or range of cell unclickable?

View 2 Replies View Related

List Range Names In Selection

Oct 11, 2007

want a list of the defined names in a selection. So lets say the range is "A1 to G60". I would like the to see a list of each cells name and the associated address.

View 8 Replies View Related







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