#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Macro Help

I need to write a macro to do some math. Cell A has a date lets say 5/15/80,
Cell G has a date lets say 5/15/06, Cell F has the eqation G-6574. If Cell A
= cell G then Place an X in cell I. This is what i have so far:

Dim i As Integer
i = 0
Range("C:c").Select
Do
activecell.FormulaR1C1 = "=RC[-1]-6574"
i = i + 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End Sub
For some reason this wont loop through all the cells, it work on the first
cell then finishes leaving the next couple cells empty even though they
should also have data in them!! Any Help would be greatly appreciated, Neal.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro Help

from your description
If Cell A = cell G then Place an X in cell I


Sub ProcessCells()
set rng = Range(Cells(2,1),Cells(rows.count,1).End(xlup)
for cell in rng
if cell.Value = cells(cell.row,"G") then Cells(cell.Row,"I") = "X"
Next
end sub

the code you show doesn't seem to have much relation to what you described.

--
Regards,
Tom Ogilvy




"Neal" wrote:

I need to write a macro to do some math. Cell A has a date lets say 5/15/80,
Cell G has a date lets say 5/15/06, Cell F has the eqation G-6574. If Cell A
= cell G then Place an X in cell I. This is what i have so far:

Dim i As Integer
i = 0
Range("C:c").Select
Do
activecell.FormulaR1C1 = "=RC[-1]-6574"
i = i + 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End Sub
For some reason this wont loop through all the cells, it work on the first
cell then finishes leaving the next couple cells empty even though they
should also have data in them!! Any Help would be greatly appreciated, Neal.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Macro Help

The first code I wrote was just to do the actual math. I didnt use the same
cells because I didnt know if the code was right. Cell F will get its value
from cell G-6574. So cell A has to be greater than cell F.So the code would
look like this?

Dim i As Integer
i = 0
Range("F:F").Select
Do
activecell.FormulaR1C1 = "=RC[1]-6574"
i = i - 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
set rng = Range(Cells(2,1),Cells(rows.count,1).End(xlup)
for cell in rng
if cell.Value = cells(cell.row,"G") then Cells(cell.Row,"I") = "X"
Next
End Sub




"Tom Ogilvy" wrote:

from your description
If Cell A = cell G then Place an X in cell I


Sub ProcessCells()
end sub


the code you show doesn't seem to have much relation to what you described.

--
Regards,
Tom Ogilvy




"Neal" wrote:

I need to write a macro to do some math. Cell A has a date lets say 5/15/80,
Cell G has a date lets say 5/15/06, Cell F has the eqation G-6574. If Cell A
= cell G then Place an X in cell I. This is what i have so far:

Dim i As Integer
i = 0
Range("C:c").Select
Do
activecell.FormulaR1C1 = "=RC[-1]-6574"
i = i + 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End Sub
For some reason this wont loop through all the cells, it work on the first
cell then finishes leaving the next couple cells empty even though they
should also have data in them!! Any Help would be greatly appreciated, Neal.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro Help

Looks like I had a typo

for each cell in rng
if cell.Value = cells(cell.row,"G") then Cells(cell.Row,"I") = "X"
Next


Add the workd each

--
Regards,
Tom Ogilvy


"Neal" wrote:

The first code I wrote was just to do the actual math. I didnt use the same
cells because I didnt know if the code was right. Cell F will get its value
from cell G-6574. So cell A has to be greater than cell F.So the code would
look like this?

Dim i As Integer
i = 0
Range("F:F").Select
Do
activecell.FormulaR1C1 = "=RC[1]-6574"
i = i - 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
set rng = Range(Cells(2,1),Cells(rows.count,1).End(xlup)
for cell in rng
if cell.Value = cells(cell.row,"G") then Cells(cell.Row,"I") = "X"
Next
End Sub




"Tom Ogilvy" wrote:

from your description
If Cell A = cell G then Place an X in cell I


Sub ProcessCells()
end sub


the code you show doesn't seem to have much relation to what you described.

--
Regards,
Tom Ogilvy




"Neal" wrote:

I need to write a macro to do some math. Cell A has a date lets say 5/15/80,
Cell G has a date lets say 5/15/06, Cell F has the eqation G-6574. If Cell A
= cell G then Place an X in cell I. This is what i have so far:
Dim i As Integer
i = 0
Range("C:c").Select
Do
activecell.FormulaR1C1 = "=RC[-1]-6574"
i = i + 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End Sub
For some reason this wont loop through all the cells, it work on the first
cell then finishes leaving the next couple cells empty even though they
should also have data in them!! Any Help would be greatly appreciated, Neal.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Macro Help

thanks for the help

"Tom Ogilvy" wrote:

Looks like I had a typo

for each cell in rng
if cell.Value = cells(cell.row,"G") then Cells(cell.Row,"I") = "X"
Next


Add the workd each

--
Regards,
Tom Ogilvy


"Neal" wrote:

The first code I wrote was just to do the actual math. I didnt use the same
cells because I didnt know if the code was right. Cell F will get its value
from cell G-6574. So cell A has to be greater than cell F.So the code would
look like this?

Dim i As Integer
i = 0
Range("F:F").Select
Do
activecell.FormulaR1C1 = "=RC[1]-6574"
i = i - 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
set rng = Range(Cells(2,1),Cells(rows.count,1).End(xlup)
for cell in rng
if cell.Value = cells(cell.row,"G") then Cells(cell.Row,"I") = "X"
Next
End Sub




"Tom Ogilvy" wrote:

from your description
If Cell A = cell G then Place an X in cell I


Sub ProcessCells()
end sub

the code you show doesn't seem to have much relation to what you described.

--
Regards,
Tom Ogilvy




"Neal" wrote:

I need to write a macro to do some math. Cell A has a date lets say 5/15/80,
Cell G has a date lets say 5/15/06, Cell F has the eqation G-6574. If Cell A
= cell G then Place an X in cell I. This is what i have so far:
Dim i As Integer
i = 0
Range("C:c").Select
Do
activecell.FormulaR1C1 = "=RC[-1]-6574"
i = i + 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End Sub
For some reason this wont loop through all the cells, it work on the first
cell then finishes leaving the next couple cells empty even though they
should also have data in them!! Any Help would be greatly appreciated, Neal.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Macro Help

Tom,
When I rewrote the code it gives me an error on the comma for line
" if cell.value= cells(cell.row,"G") the comma between cell.row,"G"
I've tried a couple things to corre3ct it and I dont know how.

"Tom Ogilvy" wrote:

Looks like I had a typo

for each cell in rng
if cell.Value = cells(cell.row,"G") then Cells(cell.Row,"I") = "X"
Next


Add the workd each

--
Regards,
Tom Ogilvy


"Neal" wrote:

The first code I wrote was just to do the actual math. I didnt use the same
cells because I didnt know if the code was right. Cell F will get its value
from cell G-6574. So cell A has to be greater than cell F.So the code would
look like this?

Dim i As Integer
i = 0
Range("F:F").Select
Do
activecell.FormulaR1C1 = "=RC[1]-6574"
i = i - 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
set rng = Range(Cells(2,1),Cells(rows.count,1).End(xlup)
for cell in rng
if cell.Value = cells(cell.row,"G") then Cells(cell.Row,"I") = "X"
Next
End Sub




"Tom Ogilvy" wrote:

from your description
If Cell A = cell G then Place an X in cell I


Sub ProcessCells()
end sub

the code you show doesn't seem to have much relation to what you described.

--
Regards,
Tom Ogilvy




"Neal" wrote:

I need to write a macro to do some math. Cell A has a date lets say 5/15/80,
Cell G has a date lets say 5/15/06, Cell F has the eqation G-6574. If Cell A
= cell G then Place an X in cell I. This is what i have so far:
Dim i As Integer
i = 0
Range("C:c").Select
Do
activecell.FormulaR1C1 = "=RC[-1]-6574"
i = i + 1
Loop Until IsEmpty(activecell.Offset(i, -1))
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End Sub
For some reason this wont loop through all the cells, it work on the first
cell then finishes leaving the next couple cells empty even though they
should also have data in them!! Any Help would be greatly appreciated, Neal.

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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 01:17 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"