English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Example: I have zero's and ones in column A and I have values in column's E, F, and G. I want the macro to look for the rows with ones in the A column cells, then add 0.25 to that row's E, F, and G column cells. So, if A8 has a 1 and E8=5.5, F8=3, and G8=2.75; A8 would stay the same, E8 would be 5.75, F8 would be 3.25 and G8 would be 3. All rows with nothing or a zero in column A remain unchanged.

2007-03-07 06:56:08 · 3 answers · asked by Sapper 2 in Computers & Internet Programming & Design

3 answers

this isn't pretty but it works.

you want to change the "for x = 1 to 10" to match the size of your data set. or you can have excel find out how many items you have but that takes more effort on my part and i'm trying to keep this simple. i also left out error trapping and defining variables but this should get you on your way. feel free to pretty it up.

Sub sapper()
Range("A1").Select
For x = 1 To 10
If ActiveCell.Value = 1 Then
ActiveCell.Offset(0, 4).Select
For y = 1 To 3
ActiveCell.FormulaR1C1 = ActiveCell.Value + 0.25
ActiveCell.Offset(0, 1).Select
Next y
ActiveCell.Offset(0, -7).Select
End If
ActiveCell.Offset(1, 0).Select
Next x
End Sub

2007-03-07 13:39:39 · answer #1 · answered by bsah 3 · 0 0

What happens if you run the macros more than once. Macros are undoable.

A simple formula on a new set of columns would suffice.

This way it only adds once. And you can see with your own eyes that it is running correctly. Copy the result to a new sheet. Pastespecial value to lock the results permanently.

Macros for this kind of situation are useful if you have a number of calculation steps and using forumlas are becoming too cumbersome.

2007-03-07 13:56:50 · answer #2 · answered by unnga 6 · 1 0

opt for the cells pass to:> format >Conditional Formatting cellular fee is: > equivalent to: > type in: =$A$a million or =40 two.5 or ="Smith" or =OR($A$a million, $A$2, $A$3) or in spite of you opt for for the condition to be. Set your format. click upload to put in yet another condition. except you're utilising Excel 2007, Conditional Formatting has a decrease of three circumstances. in any different case, you are able to record a macro or write code which will do greater, yet this is getting somewhat greater complicated. once you're searching for a thank you to make it much less perplexing to % out products in a itemizing, attempt utilising AutoFilter: opt for the full selection, pass to >documents >clear out > AutoFilter.

2016-12-14 13:12:20 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers