![]() |
Slight Error in my Simple code
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 |
Slight Error in my Simple code
Okay. So I guess there is no error in the code. I just ran through a few
things and it works.. the only problem is that I still need to enter the text and hit enter.. Which kind of makes the usefullness of my code rather... useless. I currently type in "=AutoFill(ROW(),C350)" for my cells with the code from the last post. None of my other code needs me to hit enter on the text to get it to work ( =IF($Y351<"",D350,CodeDisplay(MID($A$1,8,1),$B351 ,$B352)) ) Does anyone have an Idea why?! "Abode" wrote: 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 |
All times are GMT +1. The time now is 09:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com