If / Then For A Range Of Cells Within Macro
Apr 10, 2012
I am trying to create a macro such that in a given column (AB 0 -100), if the cell entry is "1", then another cell in the same row will be copied (C) and pasted to a third column (F).
All of the entries in column AB are 0 or 1.
So, for example, if AB23 = 1, the contents of C23 are copied, and pasted in to F23.
If AB24 = 0, nothing happens.
Code:
Dim i As Integer
For i = 1 To 100
If Range("AB" & i).Value = 1 Then
Range("C" & i).Select
Selection.Copy
[Code] ...........
View 6 Replies
ADVERTISEMENT
Mar 16, 2007
1st - Need a macro to change a range of cells colours based on a single cell having a value greater than 0.001. ie. cells A1 - G1 need to change to grey based on cell F1 having a value greater than 0.001 entered in it?
2nd - Also a macro for deleting the text contents of cell C1 based on cell F1 having a value greater than 0.001. Therefor if cell F1 has a number greater than 0.001 it changes the colour of celss A1 - G1 and also deletes the text in cell C1?
View 2 Replies
View Related
Feb 24, 2014
I have one macro to call when any value changes in a range of cells then worksheet cvhange event fires and call this macro. This macro is used to copy pivot data from one sheet to the active sheet but this is not pasting the data. here is the code .
[Code] ......
View 1 Replies
View Related
Nov 18, 2008
Just wanted to know if I could have a range or ranges which are split. The current range i have is N5:AV6. I need to miss out every 6th cell so am looking to do a number of ranges like this - N5:R6, T5:X6, Z5:AD6 etc etc. If this can be done could you show me how I would need to lay it out?
View 2 Replies
View Related
Jun 16, 2013
I am looking for a macro to put No in all Blank cells in used range of a sheet.
View 1 Replies
View Related
May 30, 2007
I am looking for a macro that will allow me to select the range of A5 to the last column with data in row 5
View 9 Replies
View Related
Oct 14, 2013
I have an excel file that contains data from bank transactions.
In column A at irregular intervals is a cell with " User Group:" It depends on how many transactions there are in a batch, could be 1 or up to say 200 as to when the next "User Group" cell is found.
After that also in column A is "Item" then "Lodgement Ref" then at the end "Batch Totals"
i.e.
User Group:
Item
Lodgement Ref
Batch Totals:
User Group:
Item
Lodgement Ref
Lodgement Ref
Lodgement Ref
Batch Totals:
I want to find each instance of "Item" then move that cell and every cell over to column CK down to and including "Batch Totals" i.e. A3401 to CK3410 to CM 3400 so it lines up with the top of the transaction block.
There are over 60,000 lines so it's worth trying to find a solution as I can then use the methodology to make other refinements in the spreadsheet.
View 9 Replies
View Related
Feb 3, 2014
I'm using this code to run a macro whenever data is entered/removed from a cell within a range. (two macros and two cell ranges).
[Code] .....
Now I need to do the same thing for a different cell range (E3:E52) and a different macro (FormatChart2). Do I need to make a new Private sub or can I add it into the existing code?
View 3 Replies
View Related
Nov 23, 2009
DoneyOte on this but i have added to the range and im now getting an error that i can't seem to fix
View 12 Replies
View Related
Jan 12, 2010
I need a macro to identify when cells are >= 90% in a range, and count them. Then put the result in cell Z58. Range is I51,L51,O51,W51,Z51. i.e if all cells are 90% then put value of 5 in cell Z58. Here is code i have that isnt working:
View 3 Replies
View Related
Jan 20, 2006
I have a worksheet with ever expanding data - rows at the bottom of the data
are continually added. I have a simple macro that sorts all of the data
according to preset parameters and selects the next blank cell in column A,
ready for more data:
Sub Macro5()
Range("SortRange").Select
Selection.Sort Key1:=Range("SortRange"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom
Do Until ActiveCell.Value = IsEmpty(True)
ActiveCell.Offset(1, 0).Activate
Loop
End Sub
When running the Macro, this leaves all of the cells in the range 'selected'
(ie; coloured-over). What do I need to add to the Macro to just select the
cell in Column A and remove the highlighting from all the other cells?
View 9 Replies
View Related
Oct 16, 2011
I have trying to develop the following macro (see below) which bases adds a column on another worksheet based on a cell value, this part works. I then want to copy the formulas from the column to the left of the inserted column, and this where I am struggling.
I found a question posed by 'TBW MK' and tried to adapt that. I can't work out how to express which needs to be copied - currently shown as Range(), given that it is a variable
Sub New_World5()
Sheets("Process").Activate
Dim ColNo As Integer
ColNo = Worksheets("Input").Range("H2").Value
With Sheets("Process")
[Code] .......
View 6 Replies
View Related
Apr 26, 2013
I have a spread sheet with large number of data, problem is all are in various currency so rather than typing =#####.##/a1 in every cell to get the GBP amount (a1 where my exchange rate is linked) I thought if there is macro can do this job for rme.
So what i need is macro which once run enter the formula after the numbers already in the cell in selected or given range.
View 1 Replies
View Related
Nov 21, 2013
I need to paste this formula
=AVERAGEIFS(A1:A1000;A1:C1000;"0";A1:A1000;"A1001") into range of cells so the changes relatively to its position e.g. in column B it will look like this
=AVERAGEIFS(B1:B1000;B1:C1000;"0";B1:B1000;"B1001") The macro I recorded will paste formula where I need, but all references remain the same. What should I do to make them change?
View 1 Replies
View Related
Feb 19, 2014
I just need to convert a range of cells into a PDF with a macro, is there a simple macro for this?
View 6 Replies
View Related
Jul 12, 2007
Reference the archives at:
http://www.mrexcel.com/archive/VBA/17448.html
How can I modify this sub to skip cells that are empty? I only want cells that are populated within the range to actually display the comment indicator, with the cell text transferred to the comment.
Ideally, I'd also like the text to be moved (not just copied) to the comment and leave an 'X' in the cell, in place of the text that was transferred to the comment, but I'll settle for the action above.
View 9 Replies
View Related
Aug 24, 2008
I want to be able to copy cell D4, I4, G10, G12 etc from one spreadsheet and paste into another spreadsheet in the same locations as the source.
Is there a macro that will do this?
View 9 Replies
View Related
May 13, 2009
I want to create a macro which asks some information like functions do. For example, I would like the macro to ask for some data to be filled by the user. For that purpose I thought about using the inputBox vba function. I wanna fill the field in the inputBox with a reference to a range from an excel sheet. So, I click on a cell and then I try to hold ctrl + down cursor to get all the range starting from that cell on until the last consecutive filled cell on the sheet. Nonetheless, the problem I have is that when I do ctrl+down cursor, I just do not get the reference I want, because it seems that the ctrl+down cursor combination does not work in the inputbox for filling a reference to a range of cells. Does anyone know some workaround to achieve this?
View 9 Replies
View Related
Nov 20, 2009
I need a macro to leave the values in a range of cells.
The macro needs to work on which ever cell is high lighted
For example if I high light cell G8 it needs to leave the value
in cell G8 to G24 then
in cell G29 to G45 then
in cell G50 to G66 etc
all the way down to the last cell range G1142 to G1158
View 9 Replies
View Related
Dec 26, 2009
how can i do the following using VBA
making each cell in column A added to each cell in column B and the result will be in the column C
for example
c1=A1+B1
c2=A2+B2
c3=A3+B3
... etc
i know i can do that simply without vba code but I just want to use this method to implement more complex formulas .
View 9 Replies
View Related
Aug 1, 2013
I need to find average of the values , the count of the cells will be dynamic (may be 5 or even 200).
View 2 Replies
View Related
Jan 8, 2009
I am looking for a macro that will check 2 things....then do something.
The first is if a range of cell values in are blank. lets say
Sheets("Sheet1").Range("D6:G48").
Next is if a particular cell contains a given value ,
Sheets("sheet1").Range("E5") should equal "Year 1" if true.
If both these are true then I want the macro to copy a range of cells from
Sheets("Sheet2").Range("H6:H48") to Sheets("Sheet1").Range("D6:D48").
I tried to use IsEmpty but it seems to return a "False" if a range of cells
are being tested.
View 3 Replies
View Related
Oct 17, 2009
The code below works fine, I can copy selected area into new sheet. However, I wish to custom change the Range("A1:AO164") value, for example, at cells(1,1) I key in A1, then cells(1.2) I key in A56, then this changes will reflect to the value in this macro to Range("A1:A56"). I tried using this way :
Dim A as string
cells(1,1).text = a
cells(1,2).text = b
Range("a:b").Select
View 2 Replies
View Related
Jun 17, 2013
I'm trying to create a macro that will change the color of the cells I've selected to green. My selection will vary depending on what cells I'm trying to color green (not a fixed range). My current code only changes one cell of my selected range:
Sub IN_PCA()
'
' IN_PCA Macro
'
'
ActiveCell.Select
Range("M243").Activate
With Selection.Interior
[Code] .......
I've tried using "ActiveRange" in lieu of "ActiveCell" as well as other commands that would seem to be correct but have failed.
View 3 Replies
View Related
Jun 22, 2009
is there a way to do this in VBA? I've also read: - Dave Hawley's recommendation of using: Sheet1.UsedRange.SpecialCells(xlCellTypeConstants).ClearContents
from another thread (which is excellent!)
- SHG's recommendation of using a named range, for example:
Range("Inputs").ClearContents
Given my limited knowledge of VBA, how would I now combine the two to write a VBA sub-routine that clears a named range entitled "Entry" on a sheet entitled "Data"? Would the following be the correct syntax: Worksheets("Data").Range("Entry").SpecialCells(xlCellTypeConstants).ClearContents
View 6 Replies
View Related
Mar 8, 2007
Sub New_Book()
Sheets("2006-07").Activate
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Sheets("2006-07").Activate
Range("A1").Select
Sheets("2006-07").Select
Range("b3").Select
ActiveCell.FormulaR1C1 = "=R[-2]"
Dim ThisFile As String
Const MyDir As String = "C:"
With ThisWorkbook
ThisFile = .Worksheets("2006-07").Range("b3").Value
. SaveAs Filename:=MyDir & ThisFile
End With
ActiveWorkbook.Save
End Sub
The above VBA works by saving a copy of existing Workbook by refering to cell A1 and then Pasting Special worksheet 2006-07 which has external links. Is it possible to create a looping macro that refers worksheet("BUs") which list all business units I need to run and save? Range(A1) needs have a looping macro that refers worksheet BUs and then automatically saves files without manually changing cell references.
View 6 Replies
View Related
Oct 30, 2012
I have a spreadsheet that allows users to paste set data from a PDF Image (using OCR) straight into Excel and then use the MID function to split the data accordingly.
Unfortunately, the OCR isn’t too intuitive and gets it wrong sometimes.
So to counter this, in another sheet (in the same workbook) I have a manual input section, and a simple macro button that pastes this data into the same fields where the OCR text would be, so that the main sheet works exactly the same way as before.
The problem is, and most likely due to the simplicity of the sheet, if a combination of OCR pasting and manual inputting is used, when I hit the paste button, it over rides the OCR data with blank cells
In the link below I have shown what is currently happening (1, 2, 3), and an example of what I would actually like it to do (4, 5, 6).
Example - Online Spreadsheets - EditGrid
So, in the 2nd scenario, I would like “5” to recognise that the respective cells in “4” already contain data and fill them ‘Grey’. This I have already achieved with basic conditional formatting.
However, I need to take it 1 step further and say that if the parent sheets cell (Auto OCR) contains data, as well as filling cells (in sheet Manual) lock these cells off and prevent the end user from adding data and/ or being copied over to the parent sheet.
Is this possible?
The result then being the parent sheet with both OCR text and copied text from the manual input sheet.
Both sheets are protected anyway and only allow for user input in certain areas, so is it even possible to apply further protection once the sheet is locked already?
View 1 Replies
View Related
Mar 20, 2007
first time posting. Need some help. I have a workbook with two sheets - (say sheet A and sheet B) that I need to copy a range from and paste (concatonated) into a new workbook. The thing is I want to copy the "non-empty" cells in columns d and e of each sheet - another words - I dont want to specify a specific cell range because users will be periodically adding new rows. Then I want to paste the "combined" from both sheets into a new sheet in a new workbook.
View 9 Replies
View Related
Jul 25, 2014
So I was given the task to translate some procedure instructions in an Excel file from English to Spanish. These are very simple instructions and in most cases repetitive throughout the document. There are a lot of instances where the instructions are the same except for a #. They are meant to be modified within the cell as the text that appears in the cell will be printed exactly as it appears.There are several instructions in the cell, it is basically a long continuous string in the cell. My idea is to create a macro that can search that range of cells for the instruction, replace it with the Spanish equivalent while leaving the original English instruction in the cell.
View 6 Replies
View Related
Dec 2, 2013
I am using Windows 7 and Excel 2010.
Is there a way to create a macro to color code a cell based on the value in a cell, and then look up a value in a table, then color code it based on where it fits into the table?
I have a table of values for about 30 projects. In column g - there is a CPI value (see bold column)
Example: Project ID
Name
Program
PMT
SI ID
AC
Milestone
TCP Level
[Code] ......
Here is the table:
I have to color code a cell, base on the CPI and how it fits into the table below. So if the current Milestone is M2 or M3 and the CPI calculated is .14 the cell would be colored RED, if the CPI number is 2.01 for M2-M3 I would want cell to be colored Turquiose. If we were at Milestone M6 and the CPI was 2.01, it would be colored blue. If the CPI was .75 at Milestone M5, it would be colored Green
LEGEND
Earned Value Limits
Milestone
RED
Yellow
Green
Turquoise
Blue
M2-M3
2.15
M4-M6
1.66
M7-M11
1.26
View 2 Replies
View Related