Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am relatively new to macros and only know how to record a macro. I am
trying to use an if formula in a macro but am not sure how. What I need it to do is if a value is = 0 then populate certain fields on a particular worksheet, and if a particular value is greater than zero then populate certain cells on a different worksheet. If there is no value then do nothing. Please help, DR |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if range("a2")0 then sheets("sheet1").range("a2").value="x"
-- Don Guillett Microsoft MVP Excel SalesAid Software "DR" wrote in message ... I am relatively new to macros and only know how to record a macro. I am trying to use an if formula in a macro but am not sure how. What I need it to do is if a value is = 0 then populate certain fields on a particular worksheet, and if a particular value is greater than zero then populate certain cells on a different worksheet. If there is no value then do nothing. Please help, DR |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The term populate can mean different types of code execution, You can copy
from one place to populate another place or you can use an array to populate a series of cells or you can directly equate the gaining cell(s) to the source cell(s). You can also use different techniques for acquiring the source data. So, it helps if you can be specific when stating your requirements as to where your source data will be, how many cells are in the range and how much of it you want to move at one shot. The code below assumes one cell for the criteria range and one cell for the receiving range, without any specific source data. Sub zeroCrit() If ActiveSheet.Cells(1, 1).Value = 0 Then Range("B1") = 'Something ElseIf ActiveSheet.Cells(1, 1).Value 0 Then Worksheets(2).Range("C1") = 'Something End If End Sub "DR" wrote: I am relatively new to macros and only know how to record a macro. I am trying to use an if formula in a macro but am not sure how. What I need it to do is if a value is = 0 then populate certain fields on a particular worksheet, and if a particular value is greater than zero then populate certain cells on a different worksheet. If there is no value then do nothing. Please help, DR |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for everyone's input. Another question: How do I tell it to skip to
the next row after it has pulled the data based on the if statement so that it doesn't copy over what is already there? "JLGWhiz" wrote: The term populate can mean different types of code execution, You can copy from one place to populate another place or you can use an array to populate a series of cells or you can directly equate the gaining cell(s) to the source cell(s). You can also use different techniques for acquiring the source data. So, it helps if you can be specific when stating your requirements as to where your source data will be, how many cells are in the range and how much of it you want to move at one shot. The code below assumes one cell for the criteria range and one cell for the receiving range, without any specific source data. Sub zeroCrit() If ActiveSheet.Cells(1, 1).Value = 0 Then Range("B1") = 'Something ElseIf ActiveSheet.Cells(1, 1).Value 0 Then Worksheets(2).Range("C1") = 'Something End If End Sub "DR" wrote: I am relatively new to macros and only know how to record a macro. I am trying to use an if formula in a macro but am not sure how. What I need it to do is if a value is = 0 then populate certain fields on a particular worksheet, and if a particular value is greater than zero then populate certain cells on a different worksheet. If there is no value then do nothing. Please help, DR |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I wrote a shortened version of what I need it to do just to see if it would
work and it doesn't. I don't know what I am doing wrong. I'm obviously in over my head, but I don't know how else to accomplish what I need. Here is the code I wrote: Sub WOSeriesTabs() If ActiveSheet.Cells(M8).Value = 0 Then Worksheets(3).Range("B4") = A8 ElseIf ActiveSheet.Cells(M8).Value 0 Then Worksheets(2).Range("B4") = A8 End If End Sub Any help would be greatly appreciated! DR "JLGWhiz" wrote: The term populate can mean different types of code execution, You can copy from one place to populate another place or you can use an array to populate a series of cells or you can directly equate the gaining cell(s) to the source cell(s). You can also use different techniques for acquiring the source data. So, it helps if you can be specific when stating your requirements as to where your source data will be, how many cells are in the range and how much of it you want to move at one shot. The code below assumes one cell for the criteria range and one cell for the receiving range, without any specific source data. Sub zeroCrit() If ActiveSheet.Cells(1, 1).Value = 0 Then Range("B1") = 'Something ElseIf ActiveSheet.Cells(1, 1).Value 0 Then Worksheets(2).Range("C1") = 'Something End If End Sub "DR" wrote: I am relatively new to macros and only know how to record a macro. I am trying to use an if formula in a macro but am not sure how. What I need it to do is if a value is = 0 then populate certain fields on a particular worksheet, and if a particular value is greater than zero then populate certain cells on a different worksheet. If there is no value then do nothing. Please help, DR |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macros or formulas not sure | Excel Programming | |||
using formulas in macros | Excel Discussion (Misc queries) | |||
formulas vs macros | Excel Discussion (Misc queries) | |||
If/Then/Else formulas in macros | Excel Programming | |||
Macros within formulas | Excel Programming |