Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I just recorded my first macros and was thrilled to have them work
properly...up to a point. The cell range in my macro is B2:B169. It did exactly what I wanted it to -- totalled the occurrences of "N", "S", "X", etc. in column B. However, when I ran the same macro in column C, it did not include the first few rows, so the totals were incorrect. I want to be able to run the same macro in column C, then column D, etc., including cells C2:169, D2:169, etc. I've read through some of the previous questions regarding macros, but to be honest, it's all over my head. I'm hoping someone can provide me with a very SIMPLE instruction on how to fix this. -- Valerie |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
post your existing code for starters, so that specifics can be addressed.
"Valerie" wrote: I just recorded my first macros and was thrilled to have them work properly...up to a point. The cell range in my macro is B2:B169. It did exactly what I wanted it to -- totalled the occurrences of "N", "S", "X", etc. in column B. However, when I ran the same macro in column C, it did not include the first few rows, so the totals were incorrect. I want to be able to run the same macro in column C, then column D, etc., including cells C2:169, D2:169, etc. I've read through some of the previous questions regarding macros, but to be honest, it's all over my head. I'm hoping someone can provide me with a very SIMPLE instruction on how to fix this. -- Valerie |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Here's what the macro looks like:
Sub DailyBathsTotals() ' ' DailyBathsTotals Macro ' ' Keyboard Shortcut: Ctrl+s ' ActiveCell.FormulaR1C1 = "=(COUNTIF(R[-171]C:R[-4]C,""=*s*""))" Range("B174").Select End Sub -- Valerie "JMay" wrote: post your existing code for starters, so that specifics can be addressed. "Valerie" wrote: I just recorded my first macros and was thrilled to have them work properly...up to a point. The cell range in my macro is B2:B169. It did exactly what I wanted it to -- totalled the occurrences of "N", "S", "X", etc. in column B. However, when I ran the same macro in column C, it did not include the first few rows, so the totals were incorrect. I want to be able to run the same macro in column C, then column D, etc., including cells C2:169, D2:169, etc. I've read through some of the previous questions regarding macros, but to be honest, it's all over my head. I'm hoping someone can provide me with a very SIMPLE instruction on how to fix this. -- Valerie |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Maybe just using the 2nd row of that column would be sufficient:
Sub DailyBathsTotals() ActiveCell.FormulaR1C1 = "=COUNTIF(R2C:R[-4]C,""=*s*"")" End Sub r2c means 2nd row, same column r[-4]c means 4 rows up, same column Valerie wrote: Here's what the macro looks like: Sub DailyBathsTotals() ' ' DailyBathsTotals Macro ' ' Keyboard Shortcut: Ctrl+s ' ActiveCell.FormulaR1C1 = "=(COUNTIF(R[-171]C:R[-4]C,""=*s*""))" Range("B174").Select End Sub -- Valerie "JMay" wrote: post your existing code for starters, so that specifics can be addressed. "Valerie" wrote: I just recorded my first macros and was thrilled to have them work properly...up to a point. The cell range in my macro is B2:B169. It did exactly what I wanted it to -- totalled the occurrences of "N", "S", "X", etc. in column B. However, when I ran the same macro in column C, it did not include the first few rows, so the totals were incorrect. I want to be able to run the same macro in column C, then column D, etc., including cells C2:169, D2:169, etc. I've read through some of the previous questions regarding macros, but to be honest, it's all over my head. I'm hoping someone can provide me with a very SIMPLE instruction on how to fix this. -- Valerie -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I still get the same result.
-- Valerie "Dave Peterson" wrote: Maybe just using the 2nd row of that column would be sufficient: Sub DailyBathsTotals() ActiveCell.FormulaR1C1 = "=COUNTIF(R2C:R[-4]C,""=*s*"")" End Sub r2c means 2nd row, same column r[-4]c means 4 rows up, same column Valerie wrote: Here's what the macro looks like: Sub DailyBathsTotals() ' ' DailyBathsTotals Macro ' ' Keyboard Shortcut: Ctrl+s ' ActiveCell.FormulaR1C1 = "=(COUNTIF(R[-171]C:R[-4]C,""=*s*""))" Range("B174").Select End Sub -- Valerie "JMay" wrote: post your existing code for starters, so that specifics can be addressed. "Valerie" wrote: I just recorded my first macros and was thrilled to have them work properly...up to a point. The cell range in my macro is B2:B169. It did exactly what I wanted it to -- totalled the occurrences of "N", "S", "X", etc. in column B. However, when I ran the same macro in column C, it did not include the first few rows, so the totals were incorrect. I want to be able to run the same macro in column C, then column D, etc., including cells C2:169, D2:169, etc. I've read through some of the previous questions regarding macros, but to be honest, it's all over my head. I'm hoping someone can provide me with a very SIMPLE instruction on how to fix this. -- Valerie -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You said you were missing the 1st few rows. could it be that your row number
is going negative because you are moving up 4 rows. This formula will only work from row 5 and up. "Valerie" wrote: I still get the same result. -- Valerie "Dave Peterson" wrote: Maybe just using the 2nd row of that column would be sufficient: Sub DailyBathsTotals() ActiveCell.FormulaR1C1 = "=COUNTIF(R2C:R[-4]C,""=*s*"")" End Sub r2c means 2nd row, same column r[-4]c means 4 rows up, same column Valerie wrote: Here's what the macro looks like: Sub DailyBathsTotals() ' ' DailyBathsTotals Macro ' ' Keyboard Shortcut: Ctrl+s ' ActiveCell.FormulaR1C1 = "=(COUNTIF(R[-171]C:R[-4]C,""=*s*""))" Range("B174").Select End Sub -- Valerie "JMay" wrote: post your existing code for starters, so that specifics can be addressed. "Valerie" wrote: I just recorded my first macros and was thrilled to have them work properly...up to a point. The cell range in my macro is B2:B169. It did exactly what I wanted it to -- totalled the occurrences of "N", "S", "X", etc. in column B. However, when I ran the same macro in column C, it did not include the first few rows, so the totals were incorrect. I want to be able to run the same macro in column C, then column D, etc., including cells C2:169, D2:169, etc. I've read through some of the previous questions regarding macros, but to be honest, it's all over my head. I'm hoping someone can provide me with a very SIMPLE instruction on how to fix this. -- Valerie -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I'm not sure what this means.
Your formula depends on the cell that you're in. It will always include the second row of that column through the cell that's 4 rows up from the activecell. If you want to always use row 2 through row 169, you could use: ActiveCell.FormulaR1C1 = "=COUNTIF(R2C:R169C,""=*s*"")" You may want to explain where the activecell is and what rows you want included--either as a relative position (4 rows up) or an absolute row (always row 2 to row 169). Valerie wrote: I still get the same result. -- Valerie "Dave Peterson" wrote: Maybe just using the 2nd row of that column would be sufficient: Sub DailyBathsTotals() ActiveCell.FormulaR1C1 = "=COUNTIF(R2C:R[-4]C,""=*s*"")" End Sub r2c means 2nd row, same column r[-4]c means 4 rows up, same column Valerie wrote: Here's what the macro looks like: Sub DailyBathsTotals() ' ' DailyBathsTotals Macro ' ' Keyboard Shortcut: Ctrl+s ' ActiveCell.FormulaR1C1 = "=(COUNTIF(R[-171]C:R[-4]C,""=*s*""))" Range("B174").Select End Sub -- Valerie "JMay" wrote: post your existing code for starters, so that specifics can be addressed. "Valerie" wrote: I just recorded my first macros and was thrilled to have them work properly...up to a point. The cell range in my macro is B2:B169. It did exactly what I wanted it to -- totalled the occurrences of "N", "S", "X", etc. in column B. However, when I ran the same macro in column C, it did not include the first few rows, so the totals were incorrect. I want to be able to run the same macro in column C, then column D, etc., including cells C2:169, D2:169, etc. I've read through some of the previous questions regarding macros, but to be honest, it's all over my head. I'm hoping someone can provide me with a very SIMPLE instruction on how to fix this. -- Valerie -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pivot Table for Dummies | Excel Discussion (Misc queries) | |||
Provide a phone # to help the dummies. | New Users to Excel | |||
Conditional Formatting for Dummies | Excel Discussion (Misc queries) | |||
DGET for dummies | New Users to Excel | |||
protection, formulas and sharing with dummies | Excel Discussion (Misc queries) |