Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Help with writing macro

Ok this is the first macro i have ever written

So, i have two worksheets sheet 2 brings in data from another source. On
column D it brings in the name of the alarm that went off.

In Sheet "Bf4 alarms" column 1 i have a list of the 710 alarms that are
known to go off.

The problem is that sometimes new alarms that are not part of this list go
off.
So, im trying to write a macro that identifies these new alarms and places
them on Sheet 1 Column 2.

I really dont knoow how to do it. this is my idea.

Obviously it doesnt work cause i dont know what im doing and an error keeps
coming up but i dont know how to make it work.

Sub IdentNewAlarm()
x = ActiveCell.Row
y = x + 1
Do While Cells(x, 4).Value < ""
Do While Cells(y, 4).Value < ""

If (Cells(x, 4).Value = Sheets("BF4 AlarmsCells").Range("A:A")) Then
Sheets("BF4 AlarmsCells").Cells(1,2).value= cells(x,4))
Else
y = y + 1
End If
Loop
x = x + 1
y = x + 1
Loop


End Sub






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with writing macro

Try this

Sub IdentNewAlarm()

'Find Last Row in column B
with Sheets("BF4 AlarmsCells")
Lastrow = .Range("B" & rows.count).end(xlup).row
NewRow = LastRow + 1
end with

RowCount = ActiveCell.Row
Do While Cells(RowCount, "D").Value < ""
ID = Cells(RowCount, "D").Value
with Sheets("BF4 AlarmsCells")
set c = .Range("A").find(what:=ID,lookin:=xlvalues,lookat: =xlwhole)
if c is nothing then
.Cells(NewRow,"B").value= _
cells(RowCount,"D"))
NewRow = NewRow + 1
End If
end with
RowCount = RowCount + 1
Loop

End Sub



"Bertha needs help" wrote:

Ok this is the first macro i have ever written

So, i have two worksheets sheet 2 brings in data from another source. On
column D it brings in the name of the alarm that went off.

In Sheet "Bf4 alarms" column 1 i have a list of the 710 alarms that are
known to go off.

The problem is that sometimes new alarms that are not part of this list go
off.
So, im trying to write a macro that identifies these new alarms and places
them on Sheet 1 Column 2.

I really dont knoow how to do it. this is my idea.

Obviously it doesnt work cause i dont know what im doing and an error keeps
coming up but i dont know how to make it work.

Sub IdentNewAlarm()
x = ActiveCell.Row
y = x + 1
Do While Cells(x, 4).Value < ""
Do While Cells(y, 4).Value < ""

If (Cells(x, 4).Value = Sheets("BF4 AlarmsCells").Range("A:A")) Then
Sheets("BF4 AlarmsCells").Cells(1,2).value= cells(x,4))
Else
y = y + 1
End If
Loop
x = x + 1
y = x + 1
Loop


End Sub






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Help with writing macro

i tried running the macro but it came up with an error box

it said run time error 1004 then when i clicked ont he d bug it took me to
this line of the macro

set c = .Range("A").find(what:=ID,lookin:=xlvalues,lookat: =xlwhole)

"Joel" wrote:

Try this

Sub IdentNewAlarm()

'Find Last Row in column B
with Sheets("BF4 AlarmsCells")
Lastrow = .Range("B" & rows.count).end(xlup).row
NewRow = LastRow + 1
end with

RowCount = ActiveCell.Row
Do While Cells(RowCount, "D").Value < ""
ID = Cells(RowCount, "D").Value
with Sheets("BF4 AlarmsCells")
set c = .Range("A").find(what:=ID,lookin:=xlvalues,lookat: =xlwhole)
if c is nothing then
.Cells(NewRow,"B").value= _
cells(RowCount,"D"))
NewRow = NewRow + 1
End If
end with
RowCount = RowCount + 1
Loop

End Sub



"Bertha needs help" wrote:

Ok this is the first macro i have ever written

So, i have two worksheets sheet 2 brings in data from another source. On
column D it brings in the name of the alarm that went off.

In Sheet "Bf4 alarms" column 1 i have a list of the 710 alarms that are
known to go off.

The problem is that sometimes new alarms that are not part of this list go
off.
So, im trying to write a macro that identifies these new alarms and places
them on Sheet 1 Column 2.

I really dont knoow how to do it. this is my idea.

Obviously it doesnt work cause i dont know what im doing and an error keeps
coming up but i dont know how to make it work.

Sub IdentNewAlarm()
x = ActiveCell.Row
y = x + 1
Do While Cells(x, 4).Value < ""
Do While Cells(y, 4).Value < ""

If (Cells(x, 4).Value = Sheets("BF4 AlarmsCells").Range("A:A")) Then
Sheets("BF4 AlarmsCells").Cells(1,2).value= cells(x,4))
Else
y = y + 1
End If
Loop
x = x + 1
y = x + 1
Loop


End Sub






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with writing macro

I should of been columns not range

from
set c = .Range("A").find(what:=ID,lookin:=xlvalues,lookat: =xlwhole)
to
set c = .Columns("A").find(what:=ID,lookin:=xlvalues,looka t:=xlwhole)


"Bertha needs help" wrote:

i tried running the macro but it came up with an error box

it said run time error 1004 then when i clicked ont he d bug it took me to
this line of the macro

set c = .Range("A").find(what:=ID,lookin:=xlvalues,lookat: =xlwhole)

"Joel" wrote:

Try this

Sub IdentNewAlarm()

'Find Last Row in column B
with Sheets("BF4 AlarmsCells")
Lastrow = .Range("B" & rows.count).end(xlup).row
NewRow = LastRow + 1
end with

RowCount = ActiveCell.Row
Do While Cells(RowCount, "D").Value < ""
ID = Cells(RowCount, "D").Value
with Sheets("BF4 AlarmsCells")
set c = .Range("A").find(what:=ID,lookin:=xlvalues,lookat: =xlwhole)
if c is nothing then
.Cells(NewRow,"B").value= _
cells(RowCount,"D"))
NewRow = NewRow + 1
End If
end with
RowCount = RowCount + 1
Loop

End Sub



"Bertha needs help" wrote:

Ok this is the first macro i have ever written

So, i have two worksheets sheet 2 brings in data from another source. On
column D it brings in the name of the alarm that went off.

In Sheet "Bf4 alarms" column 1 i have a list of the 710 alarms that are
known to go off.

The problem is that sometimes new alarms that are not part of this list go
off.
So, im trying to write a macro that identifies these new alarms and places
them on Sheet 1 Column 2.

I really dont knoow how to do it. this is my idea.

Obviously it doesnt work cause i dont know what im doing and an error keeps
coming up but i dont know how to make it work.

Sub IdentNewAlarm()
x = ActiveCell.Row
y = x + 1
Do While Cells(x, 4).Value < ""
Do While Cells(y, 4).Value < ""

If (Cells(x, 4).Value = Sheets("BF4 AlarmsCells").Range("A:A")) Then
Sheets("BF4 AlarmsCells").Cells(1,2).value= cells(x,4))
Else
y = y + 1
End If
Loop
x = x + 1
y = x + 1
Loop


End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Help with writing macro

I dont know why it still gives me an error with that line.

Now it says compile error
expected: =

"Joel" wrote:

I should of been columns not range

from
set c = .Range("A").find(what:=ID,lookin:=xlvalues,lookat: =xlwhole)
to
set c = .Columns("A").find(what:=ID,lookin:=xlvalues,looka t:=xlwhole)


"Bertha needs help" wrote:

i tried running the macro but it came up with an error box

it said run time error 1004 then when i clicked ont he d bug it took me to
this line of the macro

set c = .Range("A").find(what:=ID,lookin:=xlvalues,lookat: =xlwhole)

"Joel" wrote:

Try this

Sub IdentNewAlarm()

'Find Last Row in column B
with Sheets("BF4 AlarmsCells")
Lastrow = .Range("B" & rows.count).end(xlup).row
NewRow = LastRow + 1
end with

RowCount = ActiveCell.Row
Do While Cells(RowCount, "D").Value < ""
ID = Cells(RowCount, "D").Value
with Sheets("BF4 AlarmsCells")
set c = .Range("A").find(what:=ID,lookin:=xlvalues,lookat: =xlwhole)
if c is nothing then
.Cells(NewRow,"B").value= _
cells(RowCount,"D"))
NewRow = NewRow + 1
End If
end with
RowCount = RowCount + 1
Loop

End Sub



"Bertha needs help" wrote:

Ok this is the first macro i have ever written

So, i have two worksheets sheet 2 brings in data from another source. On
column D it brings in the name of the alarm that went off.

In Sheet "Bf4 alarms" column 1 i have a list of the 710 alarms that are
known to go off.

The problem is that sometimes new alarms that are not part of this list go
off.
So, im trying to write a macro that identifies these new alarms and places
them on Sheet 1 Column 2.

I really dont knoow how to do it. this is my idea.

Obviously it doesnt work cause i dont know what im doing and an error keeps
coming up but i dont know how to make it work.

Sub IdentNewAlarm()
x = ActiveCell.Row
y = x + 1
Do While Cells(x, 4).Value < ""
Do While Cells(y, 4).Value < ""

If (Cells(x, 4).Value = Sheets("BF4 AlarmsCells").Range("A:A")) Then
Sheets("BF4 AlarmsCells").Cells(1,2).value= cells(x,4))
Else
y = y + 1
End If
Loop
x = x + 1
y = x + 1
Loop


End Sub






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 Writing MSHO Excel Programming 4 January 11th 06 09:40 PM
writing macro EFFY Excel Programming 3 June 29th 05 05:30 PM
Help me in writing macro kishore Excel Programming 10 May 12th 05 08:20 PM
Macro Writing DFIChris Excel Programming 4 April 20th 05 04:51 PM
Help writing a macro alldreams Excel Programming 0 June 4th 04 08:24 AM


All times are GMT +1. The time now is 10:04 PM.

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

About Us

"It's about Microsoft Excel"