Loop to replace field value

  • Hi


    This should be something very straightforward for some, but its causing me big headaches!!


    I have a column (E) which contains three possible genders, Male or Female or NA.


    I have a routine which determines the number of rows in the dataset, called RowCount.


    All I want, is for a loop to start at cell E2, read it and determine if its Male or Female, and if its Male, change the cell value to 1, and if its Female, change it to 2 and otherwise, 3.


    I then want the loop to increment the rowcount by 1 and go down to the next cell, until it reaches the end row.


    Ive been trying to do something like:


    However, firstly, it doesnt like the IF statements, I keep getting the lack of End If or End Block error. Secondly, it does seem to read the cell as I have tried a MsgBox, but , it doesnt change its contents.


    Seems a really simple thing to do, but I just cant get it to work.


    Any help would be much appreciated!

  • Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags


    Just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!