deleting random amounts of data from user selected columns..

J

Jimmyc1023

I need help! I cannot seem to figure out the best way to modify a
worksheet in excel. I have a worksheet with 38 col's, and 47 rows of
data. I need to allow the user to select one or more columns, then
remove a random number cells from the selected columns. Any ideas????

***** Posted via: http://www.ozgrid.com
Excel Templates, Training & Add-ins.
Free Excel Forum http://www.ozgrid.com/forum *****
 
D

Dave Hawley

Hi Jimmy

This should get you started


Sub RandomRemove()
Dim iNumber As Integer, iLoop As Integer
Dim lRow As Long, iCol As Integer

iNumber = Int((Selection.Columns.Count * Rnd) + 1)

For iLoop = 1 To iNumber
lRow = Int((Selection.Rows.Count * Rnd) + 1)
iCol = Int((Selection.Columns.Count * Rnd) + 1)
Selection.Cells(lRow, iCol).Clear
Next iLoop
End Sub


You may want to restrict the selection to only data cells via the
SpecialCells Method.

***** Posted via: http://www.ozgrid.com
Excel Templates, Training & Add-ins.
Free Excel Forum http://www.ozgrid.com/forum *****
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Delete rows in worksheet 4
Variable column widths 3
User Defined Function 2
Pivot Table 1
matching columns of numbers 3
V 1
Two Excel forms- swapping data. 1
Converting data throughout sheet/workbooks 4

Top