ActiveCell With Multiple Cells (range)
Dec 16, 2011
I would like to select multiple active cells (in different columns) and have them copied and pasted in another sheet. The current macro I am using seem to work fine, except for the fact that it only selects cell A3 to the end of the list in that active column. I would like it to also select B3 - down, C3 - down, and E3 - down.
I "Bolded" where I think the problem lies.
Sub Sort()
Sheets("Univerity Rankings").Select
Range("a3:z10000").Select
[Code].....
View 9 Replies
ADVERTISEMENT
Apr 6, 2007
Does this code copy all cells from the active cell up to the last non-blank cell, or is it up to the first blank cell after the last non-blank cell?
View 9 Replies
View Related
Nov 4, 2008
I've been trying to get the sum of a range of cells based on their relation to the active cell. Here is the Pseudo
If the SUM of (the cell 2 rows up THROUGH the cell 2 rows up and 2 columns to the left) = 0 then .......
*****end pseudo
I think that activecell.offset is the best way to do it, but I can't figure out how to work that in a range....
Here is my code so far:
Worksheets("Generic SPC").Activate
Worksheets("Generic SPC").Range("c2").Select
'Do for all cells in the row
Do
ActiveCell.Offset(0, 1).Select
If Application.WorksheetFunction.Sum(Range( _
ActiveCell.Offset(-2, 0), ActiveCell.Offset(-2, 2))) = 0 Then
ActiveCell.Value = 0
ElseIf Application.WorksheetFunction.Sum(Range _
("ActiveCell.Offset(-2, 1), ActiveCell.Offset(-2, 3)")) = 0 Then
ActiveCell.Value = ActiveCell.Offset(-2, 0).Value
Else: ActiveCell.Value = 0
End If
Loop Until IsEmpty(ActiveCell.Offset(0, 1)) = True
******End Code
Range doesn't like activecell.offset. Does anyone know how to do this?
View 9 Replies
View Related
Mar 14, 2013
I have a custom email creation template I am merging with another version. The problem I am having is wrapping my head around not only selecting a range that is offset from ActiveCell (column 6-9) but seeing if there is an "x" in that range which is normally blank. My previous attempts identify the "x" but adds the text every time it is found. (Each column is a flag for an email bullet and they can have all four bullets in the email where I only want the text included ONCE if they have ANY bullets included). I use the range because I do not want the text included if none of the bullets are used.
Teh StandHTML then gets used in the body of the email like other HTML items I use
The email is generated using the ActiveCell.Offset to insert special text, emails and routing and has weathered alot of changes over time.
Dim Myrange As Range
Myrange = Range(ActiveCell.Offset(0, 6), ActiveCell.Offset(0, 9)).Select
If Myrange = "x" Then
StandHTML = StandHTML & "Important Text"
End If
View 5 Replies
View Related
Apr 25, 2007
I want my code to verify that the Active Cell on a worksheet falls within a specified range of cells before the sub fires off.
View 9 Replies
View Related
Aug 16, 2007
trying to make a copy range of cells from an activecell.
My activecell is P9 and I want to copy the contents of P1 to P18 without losing P9 as the activecell.
View 9 Replies
View Related
Jul 19, 2006
Can i convert this
ActiveCell. Offset(-1, 0).Copy
With ActiveCell
.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
.ClearOutline
End With
So that i can copy/paste the Offset range such as (-1,-2) (-1,1)?
View 4 Replies
View Related
Apr 23, 2009
I have a combobox which is linked to a list of policies which has information to the right of them, upon changing the value in the combobox the subroutine below is activated.
It stores the value of the combobox in a string variable, goes to the list and searches for the cell containing the policy. Upon finding the cell it uses the range offset operation to select the two boxes to the right of the active cell. This is where I get my error 1004 - application or object defined error.
Code
Private Sub cmbSectionName_Change()
Dim mySearch As String
'Assigns combobox contents to mysearch
mySearch = cmbSectionName.Value
'select the range
Application.Goto Reference:="SectionNameList"
View 9 Replies
View Related
Jan 8, 2014
I'm after a formula that will look at a number of cells(that are not in a range) with the word "C" and if they all = "C" then I want the cell to come back with the result "yes" otherwise "no".
View 12 Replies
View Related
Sep 30, 2009
I have two columns. The first column has a list of names and the second a list of numbers:
A B
SMITH 4.6
SMITH 6.2
SMITH 1.1
JONES 5
JONES 12.2
I want to get the sum of all numbers next to Smith and the same for Jones (and so on). I can autofilter and manually sum each person, but there are MANY different names and this would take a long time to do manually. Is there a formula or vbscript that I can use to automate this so I have end up with:
SMITH 11.9
JONES 17.2
XXXXX xx.x
View 3 Replies
View Related
Nov 3, 2009
So this is something that I'm not sure is possible in Excel. I would like to use an "if,then" statement to see if a number is in multiple cells. I know this is usually very simple except there's a catch here. In each cell there's a number range using a "-". So in a single cell a range would be 301-305. I am open to having the range done a different way like 301,302...etc. I just decided this would be an easy way to look at it and was hoping to find a way to solve this problem with leaving in the dash. Whatever is practical is fine with me.
Using Example A in the attached file I want to use this statement, =IF(308 is in any of the ranges in A3:A6, TRUE, FALSE).
So, for me, the alternative I want to avoid is Example B where I would have to list every single number and then check the whole range. I would like to avoid this because these examples, as you can imagine, are on a much smaller scale then what I will actually be dealing with.
View 11 Replies
View Related
Apr 24, 2012
I wish to create a Look up that looks at a range of cells on the same line Eg C6:G6
Then looks at a different tab and completes the look up.
E.g.
TCR!A:B,2,FALSE
No within the cells C6:G6 i want the formula to only use the highest match
E.g.
C D E F G
070031070031#N/A#N/A070
#N/A#N/A#N/A#N/A070
So in the first line i want the result to use the number 070031 and in the second example i want it to use 070 for the look up.
View 1 Replies
View Related
Dec 10, 2013
The following code works fine to determine if a particular character occurs within the selected range of cells:
Code:
Sub CheckIfCharacterIncluded()
For Each MyCell In Selection
If InStr(MyCell.Formula, "#") Then
MsgBox ("The " & "#" & " character was found in cell: " & MyCell.Address & " at position " & InStr(MyCell.Formula, "#"))
End If
Next
End Sub
However, I would like to extend this functionality to check for multiple characters, using some sort of array that contains all the characters I want to check for e.g. "#","*","£" and so on, without having to repeat the above code for each character for which I need to check.
View 2 Replies
View Related
Mar 14, 2014
Trying to get a problem solved to have a % discount & 'flat' $ discount apply to cell(s) referenced. Product A, B & C are available in 3 different materials. Objective is to allow each material's Max Discount column to apply discount(s) referenced in cell J3 & K3, but only in the order of applying the percentage discount BEFORE the 'flat' $ discount.
Formula in cell C3 works IF the cell "Range to apply discount" I3 = "B3". Works just fine if I allow only one cell to be displayed in I3, but ideally, I'd want this to allow the said discount(s) in cell J3 & K3 to apply to any cells mentioned (for instance, for Product A Material 1, Product B Material 2).
I had tried a drop-down menu using Data Validation, which in my actual project allows me to select ONE cell at a time (out of my list of options), which is okay, but it would be extra useful to have a checkbox option to select which ones to apply the same discount to, instead of creating a massive embedded IF function to have each product in each material find whether it's cell is referenced in 20 different places (if I just copy the already functioning single cell reference tool).
The scale in which I'd like to use this in would be to apply specific discounts for one product, but a different discount for another product or material, and allow the input cell I3 to include a checkbox drop-down option (like the filter/sort), but not remove the data in the table (Range A2:G5 in this example), so I can hide any unnecessary columns and print, showing certain products & materials having a 10% discount, while others having a 20% discount, with an additional $5 off, etc.
[URL] ........
View 2 Replies
View Related
Apr 17, 2003
how to pass multiple parameters using a range of cells to MSQuery? When I try to it tells me that I can select a single cell only. Anyone know of a new and improved sql driver to use with Excel?
View 9 Replies
View Related
Jun 4, 2014
I have a drop down list in a column called Report Type (example below).
Report Type - Drop-Down Menu in Column F
Business/Operational/Work Plan
Budget Report
Performance Report
Program Quarterly Report
Program Mid-Year Report
Program Annual/Year-End/Final Report
Service Quarterly Report
Service Mid-Year Report
Service Annual/Year-End/Final Report
Financial Quarterly Report
Financial Mid-Year Report
Financial Annual/Year-End Report
Auditied Financial Statements
In-Year Reallocation
Annual Reconciliation Report
SRI Report
Other Report
I need to count all the cells that have: Budget Report, Financial Quarterly Report, Financial Mid-Year Report, Financial Annual/Year-End Report, Audited Financial Statements, In-year Reallocation, and Annual Reconciliation Report
Is this possible with a countif formula?
View 4 Replies
View Related
May 29, 2013
I have the following table
Team>
Team A
Team A
[Code].....
I need to fill the following table in another sheet counting the amount of Blank cell there are according to Month, Team and if the name row is filled. I have tried Sumifs, sumproduct,countblank typing them in as arrays but don't seem to be getting anywhere
April
May
Team A
6
1
Team B
11
1
View 2 Replies
View Related
Jun 2, 2014
I have a target range for a worksheet change. Then when finished I highlight the data and press 'delete' I get an error within the code.
View 2 Replies
View Related
Jan 3, 2014
Is there a way to unfix multiple cell references from formulas in a range of cells at once?
View 2 Replies
View Related
Jan 8, 2010
I have tried to go around the long way to achieve this but came up with pages of pointless code .... I know there is a better way I just dont know enough about VB to do it myself ... And I know this is EASY for many :-)
--------
Cell ranges h11 to as11 are a totals row.
If the total is 0, colorindex is set to vbpatternnone, if >= 1, then colorindex is set to vbpatterngray. Easy right ? I just dont kn ow how to do FROM/IF/DO range loops...
--------
Details:
The code in worksheet_SelectionChange will contain the following:
1: From range h11 to as11, variable1 = application.interior.colorindex of the cell.
2: Check if the cell is >=1 or <=0 ....
3: If >=1 then set application.interior.colorindex = vbpatterngray. Go to #5.
' (This inserts a pattern over the original color of the cell)
4: If <=0 then set application.interior.colorindex = vbpatternNONE
ALSO set application.interior.colorindex = variable1
' (This clears the cell pattern and returns it to original color)
5. Repeat steps to clear cell pattern and restore color / or insert pattern for all cells from range H11:AS11
6. End sub
View 4 Replies
View Related
Apr 22, 2013
I'm trying to build a formula that counts the amount of cells within a range that contain multiple strings of text within the same cell. I only know how to build a formula that snags cells that contain 1 but not 2 different ones within the same cell. For example: I want to count cells if they have the word BALL and STICK somewhere in the cell....see three cell examples below
gameballnetstick
ballgame
stick ball
tenballs
green stick
Of the three examples: it would only count cells: gameballnetstick and stickball
View 2 Replies
View Related
Mar 12, 2014
I am trying to get a row of cells to highlight a percentage based on a date range
Below is an example of what my spreadsheet will look like, very simple for managers to read and understand but I am stuck on how i can get this to display the right way.
In the example i would need the Jan column to colour for a certain percent for 21 days and continue to feb for 26 days. Im not sure if this makes sense but this is what they are asking for. Colour bars to simple show the percent of days off each month.
Name Start Date End Date Jan Feb Mar
Dale 11/01/14 26/02/14 21 days 26 days
I have attached the spreadsheet for an example : Book1.xlsx
View 3 Replies
View Related
Apr 2, 2014
Basically, i have a common workbook template that is used by multiple users across the business to request a cost for numerous new products.
Within the template, there is a common section at the top, where specific project information is entered. There is also a table beneath where 1 or many products can be entered, with specific information relating to that product in the same row.
All the submitted requests are uploaded via an email attachment, to a particular sharepoint directory.
What i would like to do in the master workbook is the following:-
1. Open in turn every uploaded workbook within the sharepoint directory and copy the following cells into the master workbook, each in it's own row (or next available), with the data in adjacent cells.... 1st cell to enter data is $B6.
Cells to copy from each sheet:
Common info contained within cells:
$DG$2,$N$11,$N$12,$N$19,$N$13,$AO$7,$AO$8,$AO$9,$AO$10,$AO$11,$AO$12,$AO$12,$AO$13,$AO$14,$BO$8,$BO$11,$BO$14
Product specific info: $U37, $AD37, $AH37, $DH37, $C37, $O37
Depending on the number of products requested, we need to repeat (loop?) until it finds the next blank row in the table. I have hidden a blank row in the table, so there will always be one!
All of the common information needs to be included for each product specific entry.
For each file, once the upload has been completed, i would like the file to be moved to another "archive" directory.
I have attached the template for information. The master workbook is still in development so can't share currently.
View 12 Replies
View Related
Dec 18, 2006
Here's the situation:
I want to search through the cells in a column to locate text in one of the cells. If this text is found, I want to make that the ActiveCell and then insert a row underneath it. If this particular text is not found, I want to insert a row and put that text that wasnt found into the first cell in the created row.
I trimmed down my code a lot so I could post it here.
So, in this particular case, once the user selects one of two product lines (named "ADC" and "DAC"), I want to first search for that text and if it is found I want that to be the new activecell and insert a new row.
The main problem is that I can't seem to figure out how to set the "Foundcell" as being the new active cell. My initial activecell is set by locating and selecting the cell containing the text "Product Line".
Here's my
View 10 Replies
View Related
Aug 7, 2009
How can I select the current activecell and the next 50 following rows of that column? I cannot define a range since it has to variable.
View 4 Replies
View Related
Nov 23, 2009
ActiveCell.Activate. I'm reading through a VBA book and one line of code was
View 4 Replies
View Related
Jan 1, 2010
I want to use the following command but with more to it:
X=0
Y=0
Z=10
ActiveCell.Offset(rowOffset:=X, columnOffset:=Y).Activate
I want to use this type of command to highlight an area...not just move rows/columns. I want it to highlight from a point on the sheet marked by X and Y and then down Z rows.
So if I'm in cell A1 and want to highight from A1 down to A10, I'm not sure how to write that part of the code.
View 9 Replies
View Related
May 30, 2006
I have a list of line entries for which I need to insert a variable amount of empty lines per line. (the variable amounts listed in a column to the right of my Active Row.
Unfortunatly I loose the ActiveCell's Value. During Debug it shows the correct cell and value, but after the Debug Step Over, the value shows 0 again. I include my
[code]
Sub IP_Insert_rows()
'
' IP_Insert_rows Macro
' Macro recorded 2006/05/29 by Joseph Clark
'
Dim GrpCtrVar As Integer
Dim LnCtrVar As Integer
GrpCtrVar = 3
LnCtrVar = Range("B8").Value
View 4 Replies
View Related
Jul 1, 2006
I am working on a sub that will populate a cell based on the values of two other cells.
The ws is of variable length, the columns are A through I. I have the logic done, now I need help with the looping. It only loops through the first row. I believe that my problem is something to do with declaring the ActiveCell and looping with that. Also should I use variable names rather than Range(A2) ex. Dim EMUNCD As Variant
EMUNCD = Range("H2").Value
I have the following code so far
Sub MainMgrRpt()
Dim LstRow As Long
LstRow = Cells(Rows.Count, 1).End(xlUp).Row
For Row_counter = 2 To LstRow
Dim planCase As String
planCase = Range("F2").Value
View 3 Replies
View Related
Oct 7, 2012
Goal is to select range from active cell ( where coursos is ) to the top of that row. For some reason
ActiveSheet.PageSetup.PrintArea = Range("xey1":ActiveCell())
Does not work?
View 3 Replies
View Related