Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dr dr is offline
external usenet poster
 
Posts: 29
Default Macros in Formulas

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Macros in Formulas

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   Report Post  
Posted to microsoft.public.excel.programming
dr dr is offline
external usenet poster
 
Posts: 29
Default Macros in Formulas

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   Report Post  
Posted to microsoft.public.excel.programming
dr dr is offline
external usenet poster
 
Posts: 29
Default Macros in Formulas

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macros in Formulas

Look at it some more along with the suggestions. You'll figure it out if you
just think about it.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"DR" wrote in message
...
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macros or formulas not sure David Excel Programming 6 October 27th 07 09:29 AM
using formulas in macros BBEXCELNOVICE Excel Discussion (Misc queries) 4 November 12th 06 10:03 AM
formulas vs macros excelFan Excel Discussion (Misc queries) 4 March 23rd 06 01:45 PM
If/Then/Else formulas in macros CJ-22 Excel Programming 1 January 20th 06 05:20 AM
Macros within formulas praveen_khm[_5_] Excel Programming 3 January 16th 06 02:18 PM


All times are GMT +1. The time now is 06:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"