• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

If a column Has blank cell then put any word

Column J Already has data in it
leave the first J1 bcoz it is a headers
If column J has a blank cell then put delete word in that blank cell
I will run the macro manually
Macro will be placed in a macro.xlsm
& the file which has data is 1.xls & both files are located in diffrent place so the file path will be hardcoded in the macro(I will change it as per my needs)
sheet name can be anything
I am looking for a vba macro
 
Tell me whether I've understood correctly: You want to manually run an Excel program that

1) Opens a workbook using a hardcoded path and filename
2) Looks at the cells in column J (except the header row)
3) Any cell that is empty, put a random word in it; otherwise leave that cell alone
4) Save and close the workbook.

Is that approximately correct?
 
So something like this:
Code:
Const fnf="full path and filename"
Set owb = Workbooks.Open(fnf) 'open the workbook
Set ows = owb.ActiveSheet 'or maybe you'll have to specify the worksheet name

' Find the last used cell in column J.
Dim rZ
rZ = ows.Cells.SpecialCells(xlCellTypeLastCell).Row + 1 'one row below the last used cell in the worksheet
rZ = ows.Cells(rZ, 10).End(xlUp).Row 'now column J, up to the last cell with contents in it

' Run through the rows from 2 to rZ.
org = Range(ows.Cells(2,10), ows.Cells(rZ, 10)) 'set a range equal to the cells we're interested in
For Each oc In org.Cells 'look at each cell
  If IsEmpty(oc.Value) Then 'put some random word in there
  Next oc

You can decide yourself what to put in each cell. If you want to it to be a different word in each cell, then you need to make a list of possible words and pick one at random each time. Or you can construct a random string of characters (if it doesn't actually have to be an English word). I'll wait for you to ask; maybe this is all you need.
 
Back
Top