Select Range Based On Variable Cell Content
Based on if the value in col A contains the characters "TT" I want to select the range starting with this cell and ending at the end at the end of the row I'm using (.End(xlRight) and then merge these cells, change colors etc. And then looping this through a 'range' so that it only occurs where the values occur. I can amend various cells based on this idea, but am unable to identify the range and then merge the cells.
View Complete Thread with Replies
Related Forum Messages:
Select Sheet Based On Cell Content
I am trying to do some thing simple, but i causes me a lot of problem in several areas. I am using the
to simply select the sheet that is named in cell c5 on the current sheet. can anyone give me a correct way to accomplish this that I can use in other applications that i come accross?
How To Select Range And Clear Based On LR Variable
I want to select and clear a part of a sheet.
here is what I have.
lr = activesheet.usedrange.rows.count
Here is where I get lost in translation (syntax).
I want to select starting at Bcolumn through bycolumn but the row be set with the LR from above, since the rows always change.
I could write B2:by2000, but i want to use the LR variable to define the number of rows i have.
Select Range Based On A Cell Value
I have a worksheet with a block of data. The size of this block changes.
I am calculating and storing the upperleft and lower right cell position of the block in say cells AA3 and AB3 on the same worksheet.
So far I have everything working fine.
Now I want to create a button to trigger a macro to sort that block.
I can figure out the button and make it trigger a macro.
One of the lines in the macro is
Select A Variable Based On A Variable
On my userform I have 20 comment icons (imported pictures), that when clicked need to bring up an InputBox for the user to add a comment, and store that comment in a Public variable specific to that comment which will later be written to the spreadsheet.
To keep it simple, lets say I have two comment icons to click, one to add comments to the "Testing Completed?" field, and one to add to the "Sign-Off?" field.
The first comment icon is named TestCompIcon, the second is SignOffIcon, and the public variables they write to are called TestCompComment and SignOffComment respectively.
To avoid having to code the InputBox procedure for every comment icon on the userform, I was hoping that upon click, the icon would call a centralized routine that would establish the name of the variable that needs to be written based on the name of the icon comment that was clicked. Something like as follows:...............
Select A Range Based On Active Cell Location?
I'm trying to select a range of cells whereby the range is dependent on the currently active cell. I know you can use the "Activesheet.Range("A1:D2").select" method to select a range where the cells are always the same, but I'm after a dynamic selection where the values can be programmatically altered depending on some other result.
For example, let's say that I make a certain cell active (based on the result of some other formula), and I want to select the range of cells in the adjacent column that is X rows deep. Putting this into context, imagine the resultant active cell is B2, I then want to select the range C2:C10, but if the active cell is E10, the range selected would be F10:F18 (if active cell is X, then range would be Y:Z).
The Offset function would allow me to position the cell based on the current active one, but it doesn't let me select a range. The Range function only lets you choose either hard coded or index cells, e.g. "Range(cells(y,z), cells(y,z)).select", but this is still no good because I'd need to know the index value of the active cell (can this be done?).
Select Cell Content From Visible Rows.
I have a worksheet whereby many of the rows are hidden. These rows were initialy hidden by means of scipts ( I have numerous scripts to hide data under various criteria) eg: Scripts which hide rows based on cell count, cell color, cell data information etc...
Now that I am able to veiw only the information that i want to see.. is it possible to create a script which selects cells only from rows which are visible? I have created a Named range begining from E:12 to G:500 called "Select_EFG"
Uing the example below, how could I select the cell data from the visible rows (12, 30, 34, 35, 50 etc... up to row 500.) from this Named Range (columns E:12, G:500) .... and paste this information in Sheet 2 Row5 columnC
Variable Range Select - Then Clearcontent
This one should be easy but I keep running into the same wall.
On every page I have single cell defined name range based on the sheet name & "_startcell"
So on sheet MfgReq I have cell A3 defined as name range "MfgReq_startcell".
I would like to the following:
.clearcontent using the "MfgReq_startcell" as the upper most left cell, all the columns to the right, and all the rows down.
on this sheet it might be 5 columns wide by 4000 row & on another sheet it might be 50 columns wide by 50000 rows.
Select Variable Print Range
I am trying to create a command button on my userform that will allow me to print all the records in the worksheet....in other words it should only print the rows with data......
*my worksheet is called "complaintData" - this is hidden and not active sheet.
*I have columns A to J with information, with heading from A1:J1.
*I want to be able to print all the rows with values in column A. (Not all the columns except "A", will have values for every record....some may be blank for some records...
*I want all the columns to fit in in one page with headings (A1:J1) being first row on every new page.....
*page setup should be landscape...
I have tried a few codes from this forum, but not sure where I have goofed up....am still trying learn VBA.....would appreciate if anyone can fix this code for me....cheers
Private Sub cmdPrint_Click()
Sheets("ComplaintData").Visible = False
Dim ws As Worksheet
Set ws = Worksheets("complaintdata")
Select Range With Row Variable
I am doing is setting a variable called eof to the number of rows (with text) and i just want to select columns A1 - G1 and the eof range!
Dim eof As Integer
With Sheets("Coverage Count (%)")
eof = .Range("G65536").End(xlUp).Row
'crashes on the .select
.Range("A1:G1" & eof).Select
Selection.Sort Key1:=Range("G2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
I've done this before and I could have sworn this worked...but i must be missing something.
Select A Variable Range Macro
I have tried various syntaxes but nothing is working for me. I am using XL 2000 so it doesn't have the relative address function in the macro! So here is what I have
Application. ScreenUpdating = True
I need to be able to select from the originating cell which will always be in "T" Col thru to "CZ" col but will be on different rows.
Select Variable Data Range For Graph
I need to select data from columns A, B and I for the graph. I have the below code but get an error message. Can anybody help ?
Set cellGR1 = Cells(2, 1)
Set cellGR2 = Cells(K, 2)
Set cellGR3 = Cells(2, 10)
Set cellGR4 = Cells(K, 10)
Select/process Variable Range With Macro
I download some data from a commercial real estate site about properties and their owners and process it in Excel. Out of 1,000 records, maybe 20 or so will have the data end up in the wrong fields. This is an artifact of the data source the commercial site uses.
Anyway, what I need to do is to get the data back in the right fields. So, I sort the data to pull together at the top of the sheet all the records with data where it's not supposed to be. So far, so good.
Now from one data download to another the number of records which end up in the sort will be different. And, here's the problem.
I try to record a macro mimicking my selection of the range of the data that needs to be moved. Fine, no problem. And, on the same dataset it works like a charm. But as soon as I put a different dataset into the spreadsheet with a different number of records that need to be corrected the macro fails.
Apparently, this is because the macro has been defined with a certain range of cells selected in the first data set and this same range is used for subsequent datasets with different numbers of errant records.
Basically, what I'm trying to record in a macro is the Shift/Control End and Shift/control arrow commands. But they don't record as such.
Add Value Based On Cell Content
I have a named range (D:16 F:800) called “NameRange” which contains names.
I’d like to create a macro which offsets a letter “x”, 10 columns to the right everywhere that name appears within the range. As an example: If I’m trying to find the name Tom, A dropdown menu shows the name “Tom” ( which I’ve created) whereby it calls upon a script to search within the named range from this:
Bob Kim Tom
Mary Bill Ted
Tom Sue Bob
Fred Bill Sue
Bob Tom Kim
and offset “x” to look like this:.......
Deleting Rows Based On Cell Content
I wish to remove the page headers that were imported along with the raw data. Here's the code I've been using.
Column_To_Check = 3
Start_Row = 1
End_Row = ActiveSheet. Cells(Start_Row, Column_To_Check).CurrentRegion.Rows.Count
Search_String = "."
For Row_Counter = Start_Row To End_Row
If ActiveSheet.Cells(Row_Counter, Column_To_Check).Value <> Search_String Then
Row_Counter = Row_Counter - 1
When I import the data from the text file, there are 3 dimensions separated by a period in the same field. I.E: ABC.DEF.GHI and I use the break points to seperate as such: ABC|.|DEF|.|GHI|. Therefore, all rows that contain data also contain a period in cell C, but headers don't.
End_Row = ActiveSheet.Cells(Start_Row, Column_To_Check).CurrentRegion.Rows.Count
CurrentRegion only selects up to the first blank row. However, I need this to select the whole sheet, not just the current region.
Format Border Based On Cell Content
I have a dynamic table (rows regularly added or deleted) that is generated automatically based on choices made by the user in another worksheet. I need a function that will examine all the cells in one column, and when it finds a difference between two cell entries, it will change the border between these two entries to dark (medium weight), and then extend this border across the table. The end result should be that wherever the cell contents differ within a column, the table is divided by a darker border across the entire row.
Run Macro Based On Cell Content
I have a drop down list made from the Forms toolbar with a list of items: 1, 2, 3, 4, 5. I have set it with a linked cell, so when you choose, say 3, from the dropdown, 3 appears in B10.
I was hoping to add a 'Go' button, which would run another macro depending on what is in B10, i.e. so if 3 was chosen, then you press 'Go', Macro3 would be run.
So I have 5 macros called Macro1 - Macro5, and I need some code for the 'Go' button which will run the right macro depending on what number is in cell B10.
Setting Colour Of Cell Based On Content
I have inherited a spreadsheet from someone else that rather cleverly (in my humble opinion) sets the colour dependant on the contents. ie negative value is red, zero is amber and positive is green.
i like the idea and would like to use it on a spreadsheet of my own, but have tried to find out how it is done and can't!
Changing Cell Content Based On Button
I have created two buttons in a worksheet to navigate to two other worksheets. I would like a cell to display 'YES' automatically if one of the two buttons is clicked and or to display 'NO'. I also would like to change the colors of these cells change automatically depending on which button is pressed.
Conditional Formatting Based On Cell Content
I am trying to format cells based on what is in them across the board. Is there a way to conditional format based on what is in certain cells? I have 5 columns. I need to color in every NA only in the rows that have 1 or less cells with a number in there. So if there is 2 cells in that one row that have a number in them then leave the whole row white. If there is only 1 number in that row and the rest are NA then color all the NA's in red......
Lookup Data Based On Cell Content
I am setting up a worksheet (1) with a full list of part numbers supplied, cost etc. ie:
Part Description Price Qty
1234 Blah Blah £1.00 1
1235 Blah Blah £3.00 0
1236 Blah Blah £2.00 2
And I have set up a seperate worksheet (2) as an invoice. What I have been trying to do is when I enter a qty in worksheet (1), worksheet (2) will reconise an entry in the qty colum an copy selected fields/ cells. I can do a "=" or use an "if" statement looking at anything greater than "0". but is there a way I can get the invoice worksheet to ignore any lines with "0". So it will only copy over the information with only qtys for the invoice ?.
Drop Down List Based On Cell Content
I'm trying to find a macro that will allow me to enable several drop down lists in the same cell based on the content of another cell. In other words:
If cell A1 is the data entry cell, and the user enters "cat"
Then cell B1 will display a drop down list of previously grouped options: "mouse, bug, bird"
If in cell A1 the user enters "dog"
Then cell B1 will display a different list of previously grouped options: "mole, rabbit, kibble"
Display Image Based On Cell Content
I'm trying to display a different image based on the contents of a cell. For example if cell A1 = "Gerrard" I would then like to display a picture of Steven Gerarrd. Is this possible? If so can anyone give me a steer in how I might acheive this.
Return Number Based On Cell Content
I have a questioner in a excel spreadsheet. Column C have yes or no answers. If answer yes is implied then I want the number 2 to appear in Column F of no is implied then the number 3 will appear. I am having trouble writing the language for this.
Change Cell Color Based On Cell Content
I have a chart full of different names which I need to separate them by color when a specific entry is found in a Cell. For example the list has the store name "ZELLERS" + its branch number. (ex. ZELLERS #276 PL or ZELLERS #295 SL and so on). I would like to modify the below code so that It only check for the name ZELLERS and not the branch number. If it finds ZELLERS in any cell In the Range of C1:C500 then color it Red.
Below Code does that but I have to write the exact name as it appears in the cell otherwise it wont find it for me. Is there any way to resolve the issue? I am not an Excel Programmer but Only an Excel user.
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("C1:C500")
If Intersect(Target, r) Is Nothing Then
On Error GoTo Endit
Application.EnableEvents = False
vals = Array("ZELLERS #276 PL", "ZELLERS #295 SL", "Gopher", "Hyena", "Ibex", "Lynx")
nums = Array(3, 46, 6, 3, 7, 4, 20, 10, 23, 15)
For Each rr In r..........................
Formatting Row Of Cells Based On A Cell Content
I want to format a range of cells based on the name listed in a cell in column A (starting @A6). I currently do this manually. It is to help me visually see the line I am working with and for what person.
I am almost certain that is going to take a VBA, but I know little to nothing about setting one up.
I have attached a sample. I am using Excel 2003.
Assign Names Dynamically Based On Cell Content
I do have a data set from A1:C8 as follows:-
Brand Name(A1)Sales Value(B1)Margin(C1)Levi's100002000Arrow150002500Allen Solly120001300Hanes80001000John Miller250004500Disney280003200Ray Ban180002100
The above brands are categorized as follows:-
Brand NameProposed CategoryLevi'sConsignmentArrowBrandAllen SollyBrandHanesBrandJohn MillerPrivate LabelDisneyBrandRay BanConcessionaire
I would like to put formula from D1:D8 in such a way so that the Proposed categories are extracted automatically through formulae. This will help in getting the contribution calculated from different categories.
Brand Name(A1)Sales Value(B1)Margin(C1)Category(Desired Result)(D1)Levi's100002000ConsignmentArrow150002500BrandAllen Solly120001300BrandHanes80001000BrandJohn Miller250004500Private LabelDisney280003200BrandRay Ban180002100Concessionaire
Macro For Saving Filename Based On Cell Content
Is it possible to create a macro attached to a button that allows me to save the workbook based on content of 2 cells in the workbook?
I like to save the workbook based on content of cell A4 that contend a text string. After that saving another time with the contend of cell A4 plus cell A9 which contend the today() function. I am doing this because this workbook is constantly updated and a backup copy is done based on the date the file is save.
External Data Query Based On Cell Content..
I have a sheet which is running a a query against an external source, and coming back with a list of client data. Each row is an investment with it's own unique InvestmentID number and a ClientID number. Each client has their own unique ClientID, however may have multiple investments (InvestmentID) linked to their ClientID (does that make any sense?!).
Anyway, the query I have returns ALL investments. I know how to manually change this to only bring back certain client(s), however I want to be able to have the users (who don't know what a query is, yet alone to how to use/edit one) enter a ClientID into say, cell B2 and have the query reflect that ClientID. If they have to click a button to run a macro after entering the ClientID, so be it (although it'd be great if it actioned once they hit "Enter").
I know this is possible because I've used something similar before (that someone else created!). What I don't know is... if I had multiple "entry cells", could I have the query filter by two (or more?) ClientIDs? That is, they enter the first ClientID in B2 and the second ClientID in C2, the query then returns all information relating to B2 or C2
Remove Cell Content Based Upon Not Starting With A Word
I am working on a macro and, as part of it, I would like to look at column A of my spreadsheet and remove all cell contents where the text in the cell does not start with the word "total." For instance, if the text of a cell in column H is "total money" I would like it to remain unchanged. However, if the text of a cell is "George Baker" I would like it removed. I ONLY want the text in column H to be considered ... no other column.
How To Lookup Row # Based On Content Of Another Column's Cell
I have a 3 column table with 20 rows. The first two columns contain travel
expense data. The cells in the third column are blank exept for whichever
cell I enter an "x" in. Please let me what formula or worksheet function do
I use to calculate the travel expenses based on the data in the first two
columns that correspond to the row of the cell with an "x" in the third
Subtract Cell From Others Based On Cell Content
I am trying to create a formula that will compute a variance between the numeric value in a given cell with the value in one of 3 other cells depending on the condition of the 1st cell. Example: If the Value in cell F4 has a condition defined as "PMR" in cell C4, subtract the value in cell F19 from F4. If the condition is defined as "DBR" in cell C4, subtract the value in F20 from F4. And if the condition is "OTH", subtarct the value in F21 from F4.
Adding Multiple Row Contents Based On The Content Of A Single Cell
Been trying to work this one out and have ended up banging my head against the wall.
Basically I have a spreadsheet, in the first column is the person's name, in the secon which team they are in and following this a cell for each day of the month with their availability.
The team name is a selection from a list, the availability is 1-6 (different levels of availability)
I'm trying to do subtotals at the bottom for each separate team, so the very last row each of the cells for each is added up:
Name Team 1st 2nd 3rd 4th 5th 6th 7th etc.
Mr X ___1st___1______2__1
Mr Y ___2nd_______2________5__5__5
Mr Z ___1st___1____________3__3__3
Total 1st: 2 2 1 3 3 3
Total 2nd: 2 5 5 5
So basically the formula in the last row goes along the lines of:
Add each cell in the column IF the team name = 1st
Read Cell Content & ADD Content + Font Properties *SOLVE
I use this to read cell content, add some text/characters (ie. [ and ]) and change the properties of the complete cell
If ActiveCell.Value 0 Then ' Change all in to ... ... ...
ActiveCell.FormulaR1C1 = ActiveCell.Value & " " & "]" & " " & "["
.Name = "Arial Narrow"
.Size = 8
.ColorIndex = 16
HOW can I change this vba-code so it leave's the content of the cell like it is and add some content with the use of let's say TexBox1 and ONLY use different font properties for the newely added content?
Passing Cell Content As Named Range In Formula
how to pass a cell content into a formula as a named range? For instance, I have 3 named range (Budget, Actual, Forecast) and I use the named range in vlookup formulas. But instead of using the named range in the formula directly, I want to refer to a cell where I can type in which named range I want to use. Can this be done? I am attaching a sample spreadsheet to clarify what I mean.
Lock Empty Cells In Range Based On Other Cells Content
I am trying to lock the unused cells in 32, 2 column by 7 row named ranges, based on whether or not two cells, above each range are equal or less than each other. In other words while one of the cells is less than or equal to the second cell all cells in the range below should be unlocked, as soon as that condition is no longer true the blank cells need to be locked.
I am trying to use this in the Workbook_Sheetcalculate so that the macro will run automatically.
Highlight/Select TextBox Content
i am working on a userform that contains several controls one of which is a textbox ,everything is fine except that i need to know which textbox property to use in order to highlight the text writen inside the textbox, i know "setfocus" but thats not excatly what i need, i need to highlight the text inside the textbox.
"textbox.setfocus" sets the focus onto the textbox without highlighting its content
what i need is:
"textbox.ur suggestion" sets the focus onto the textbox & highlight its content, this way i will no longer have to clear the text using the backspace key to write another text
Select Dynamic Range Based On Non-empty Cells
I require code to identify the last row in column 'A' that contains data, and then to select every row up to that one, and each column up to 'H'. My data begins on row 3, and the rows with data varies from row 7 through 120. The columns with data is constant so there is no need to test in that direction.