Select Empty Cells Write Value

OminousDark

New Member
Joined
Jul 23, 2014
Messages
14
Hello, In my worksheet I have a column for roles of members - these are defined as "X", "Y", "Z" on my first worksheet ("X1"), although under the roles column in worksheet ("X2") it only lists fields for "Y" and "Z" as they are the more unique roles, and for "X" the fields are just blank. What I need is some VBA code to be able to write in "X" in all the blank fields under the "Roles" heading, but ONLY if it is meant to be apart of the participants data (I don't want "X" to be listed all the way down to row 1000000) possibly make it detect data to the left/right of the empty field?

Any help would be great, sorry if its hard to understand please just ask if you need some more information!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Ok, which column contains the "roles" and which column requires an "X" and what sheet does this apply to ??
 
Upvote 0
sorry - ok so, Roles is in column I, Column I needs "X" in the blank spots - and it applies to sheet "X2"

atm Column I has "Z" and "Y" and Blank - "X" needs to fill in those blank spots, but only to the last participants information - Although needs to be able to go further if more mpeople are added.
 
Upvote 0
OK, but what column on Sheet "x2" are we looking at to determine whether an "x" needs to be inserted in Col "I" of the Sheet "x1"
 
Upvote 0
sorry - ok so, Roles is in column I, Column I needs "X" in the blank spots - and it applies to sheet "X2"

atm Column I has "Z" and "Y" and Blank - "X" needs to fill in those blank spots, but only to the last participants information - Although needs to be able to go further if more mpeople are added.
Give this a try...
Code:
Sub PutXinBlankCells()
  On Error Resume Next
  Sheets("X2").Range("I1:I" & Sheets("X2").Columns("H:J").Find("*", , _
    xlValues, , xlRows, xlPrevious).Row).SpecialCells(xlBlanks) = "X"
  On Error GoTo 0
End Sub
 
Upvote 0
That did not work sadly, Thanks anyways, I will try to explain it a bit better with different names for things now as I think my explanation was really bad.

Worksheet Name: Combined
Columns: A to J.
Column in which Role heading is located: I
Data under the Role heading: "D" and "S"
Column to the Left of Role (H): Postcode
Column to the Right of Role (J): Category
Rows: 3039

What I need it to do: Input "P" into all the BLANK spots in Column I as long as there is data to either the LEFT (H) or RIGHT (J) of the BLANK field. It should NOT ONLY go to I1:I3039 as MORE names / Information will be added in later down the track. (Thus the detect information to either side of it).

Row 1 is Headings.

Forget the second Worksheet, it is not of importance.

Sorry - Hope this information helps I greatly appreciate the help :)

- OminousDark
 
Upvote 0
That did not work sadly, Thanks anyways, I will try to explain it a bit better with different names for things now as I think my explanation was really bad.

Worksheet Name: Combined
Columns: A to J.
Column in which Role heading is located: I
Data under the Role heading: "D" and "S"
Column to the Left of Role (H): Postcode
Column to the Right of Role (J): Category
Rows: 3039

What I need it to do: Input "P" into all the BLANK spots in Column I as long as there is data to either the LEFT (H) or RIGHT (J) of the BLANK field. It should NOT ONLY go to I1:I3039 as MORE names / Information will be added in later down the track. (Thus the detect information to either side of it).
See if this code works for you...
Code:
Sub PutXinBlankCells()
  Dim LastRow As Long
  LastRow = Sheets("Combined").Columns("H:J").Find( _
            "*", , xlValues, , xlRows, xlPrevious).Row
  Sheets("Combined").Range("I2:I" & LastRow) = Evaluate(Replace( _
     "IF((Combined!I2:I#="""")*(LEN(Combined!H2:H#&Combined!J2:J#)>0)," & _
     """P"",IF(Combined!I2:I#="""","""",I2:I#))", "#", LastRow))
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,267
Members
449,219
Latest member
daynle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top