G
Guest
This is getting rather aggrivating. I swore this code worked for the most
part yesterday. Anyway, I am trying to write a code that will Automatically
fill in Data if there is an entry in the Y column. If there is nothing in
the Y column and there is nothing in the B column or B column of the next row
it will write three dashes. The code is ment simple to make my life easier
and fill in typical data (Most of my Spreedsheet is filled with NAs and other
such data) Between groups of common entries I keep spaces to keep it easy to
read. I perfer to have my code automatically fill itself in with Dashes
where no data is needed and it is not a space between comon entries. My code
thusfar is:
Function AutoFill(RowNum, TrueFill)
If (Range("Y" & RowNum).Value) <> "" Then
AutoFill = TrueFill
Else
If (Range("B" & RowNum).Value = "") And (Range("B" & (RowNum +
1)).Value = "") Then
AutoFill = "---"
Else
AutoFill = ""
End If
End If
End Function
Where RowNum is the RowNumber. I think the problem is somewhere with the
Range("B" & Rownum).Value = "". I've tested the code several ways and the
First Range does work. For some reason if there is no value in the Y Column
then The If statement testing both values in the B column is always true.
Id imagine that if there is a error the If statement would automatically
produce a False. Alse when I enter the Function into Excel I have to click
on the cell, then select the text and hit enter for any changes to take
place. I dont believe I've ever had to do that before.
Wow, this is a rather long post. Anyway, I am sure the fix is simple, I
just can't figure it out.
Mark
part yesterday. Anyway, I am trying to write a code that will Automatically
fill in Data if there is an entry in the Y column. If there is nothing in
the Y column and there is nothing in the B column or B column of the next row
it will write three dashes. The code is ment simple to make my life easier
and fill in typical data (Most of my Spreedsheet is filled with NAs and other
such data) Between groups of common entries I keep spaces to keep it easy to
read. I perfer to have my code automatically fill itself in with Dashes
where no data is needed and it is not a space between comon entries. My code
thusfar is:
Function AutoFill(RowNum, TrueFill)
If (Range("Y" & RowNum).Value) <> "" Then
AutoFill = TrueFill
Else
If (Range("B" & RowNum).Value = "") And (Range("B" & (RowNum +
1)).Value = "") Then
AutoFill = "---"
Else
AutoFill = ""
End If
End If
End Function
Where RowNum is the RowNumber. I think the problem is somewhere with the
Range("B" & Rownum).Value = "". I've tested the code several ways and the
First Range does work. For some reason if there is no value in the Y Column
then The If statement testing both values in the B column is always true.
Id imagine that if there is a error the If statement would automatically
produce a False. Alse when I enter the Function into Excel I have to click
on the cell, then select the text and hit enter for any changes to take
place. I dont believe I've ever had to do that before.
Wow, this is a rather long post. Anyway, I am sure the fix is simple, I
just can't figure it out.
Mark