Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Where to put code

Using MSOffice2003
On my spreadsheet, I want to do this:

If C15.value 0 then D15.value = 65
Then I want to copy this down these two rows.

Where do I put this code, and am I using proper Excel VBA syntax?

Thanks for your help.

Joanne
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Where to put code

Sub joanne()
For i = 15 To Cells(Rows.Count, "C").End(xlUp).Row
If Cells(i, "C").Value 0 Then
Cells(i, "D").Value = 65
End If
Next
End Sub

Put this in a standard module

--
Gary''s Student - gsnu20076b


"Joanne" wrote:

Using MSOffice2003
On my spreadsheet, I want to do this:

If C15.value 0 then D15.value = 65
Then I want to copy this down these two rows.

Where do I put this code, and am I using proper Excel VBA syntax?

Thanks for your help.

Joanne

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Where to put code

Gary''s Student wrote:
I copied your code into a standard module in my workbook as you
instructed, but it does not do the intended deed.

As I understand the code, it is creating an index of all cells in col
'c' starting with row 15 to the end of the row - then looking (row by
row) to see if the cell in c has a value greater than 0 - if so, then
the cell in that row in col 'd' should be equal to 65. Is that right?

It seems a simple thing. I don't understand why it doesn't work. I have
the cells in question formatted for currency with a leading $ - would
that make any difference?

What I am trying to do on the spreadsheet is make col D = 65 only in the
rows where there will be a value 0 in col C - maybe I am taking the
wrong approach altogether?

Thanks for your interest in my problem
Joanne

Sub joanne()
For i = 15 To Cells(Rows.Count, "C").End(xlUp).Row
If Cells(i, "C").Value 0 Then
Cells(i, "D").Value = 65
End If
Next
End Sub

Put this in a standard module



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Where to put code

You probably just need to be sheet specific since it is in a module.
Sub joanne()
For i = 15 To Sheets(1).Cells(Rows.Count, "C").End(xlUp).Row
If Sheets(1).Cells(i, "C").Value 0 Then
Sheets(1).Cells(i, "D").Value = 65
End If
Next
End Sub

change the 1 to your sheet number or name.

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Joanne" wrote:

Gary''s Student wrote:
I copied your code into a standard module in my workbook as you
instructed, but it does not do the intended deed.

As I understand the code, it is creating an index of all cells in col
'c' starting with row 15 to the end of the row - then looking (row by
row) to see if the cell in c has a value greater than 0 - if so, then
the cell in that row in col 'd' should be equal to 65. Is that right?

It seems a simple thing. I don't understand why it doesn't work. I have
the cells in question formatted for currency with a leading $ - would
that make any difference?

What I am trying to do on the spreadsheet is make col D = 65 only in the
rows where there will be a value 0 in col C - maybe I am taking the
wrong approach altogether?

Thanks for your interest in my problem
Joanne

Sub joanne()
For i = 15 To Cells(Rows.Count, "C").End(xlUp).Row
If Cells(i, "C").Value 0 Then
Cells(i, "D").Value = 65
End If
Next
End Sub

Put this in a standard module




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Where to put code

remove wrote:
That did not help any. Still no value dropped in row on col D. Should I
be using the column headers for cols C and D instead of just 'C' and
'D'?

The code is in a module, not on the ws or in the wb. This is correct?
Sub is named LaborRate, which I believe should be okay.

Thanks for your time on this
Joanne



You probably just need to be sheet specific since it is in a module.
Sub joanne()
For i = 15 To Sheets(1).Cells(Rows.Count, "C").End(xlUp).Row
If Sheets(1).Cells(i, "C").Value 0 Then
Sheets(1).Cells(i, "D").Value = 65
End If
Next
End Sub

change the 1 to your sheet number or name.





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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
How to assign same code inside Option button code space ?? furbiuzzu Excel Programming 1 November 21st 06 02:36 PM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 07:03 PM.

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"