Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Fill MT cells in a range

Hello Folks!

My VBA knowledge is slim to none so I need a little help
with a macro.

I would like a macro that fills MT cells in a range with
random uppercase letters A-Z. The cells will not always be
contiguous. I'm playing around with a word search puzzle
and looking for a quick way to fill the MT cells.

Thanks for your help
Biff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Fill MT cells in a range

Biff,

I dont know what you mean with MT cells,
but does this work for you?

If fills the selected cells..


Sub FillPuzzle()
Dim c As Range
Randomize
For Each c In Selection.Cells
c = Chr$(64 + Int(26 * Rnd + 1))
Next
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Biff" wrote:

Hello Folks!

My VBA knowledge is slim to none so I need a little help
with a macro.

I would like a macro that fills MT cells in a range with
random uppercase letters A-Z. The cells will not always be
contiguous. I'm playing around with a word search puzzle
and looking for a quick way to fill the MT cells.

Thanks for your help
Biff


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Fill MT cells in a range

Thanks keepITcool !

Yes, that works. I think I can figure out just enough to
tweak it a little. Well, maybe not.....but I'll try it.

At what line of that macro would I add code to make the
selection of the MT(empty) cells automatic?

Thanks
Biff

-----Original Message-----
Biff,

I dont know what you mean with MT cells,
but does this work for you?

If fills the selected cells..


Sub FillPuzzle()
Dim c As Range
Randomize
For Each c In Selection.Cells
c = Chr$(64 + Int(26 * Rnd + 1))
Next
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Biff" wrote:

Hello Folks!

My VBA knowledge is slim to none so I need a little

help
with a macro.

I would like a macro that fills MT cells in a range

with
random uppercase letters A-Z. The cells will not always

be
contiguous. I'm playing around with a word search

puzzle
and looking for a quick way to fill the MT cells.

Thanks for your help
Biff


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Fill MT cells in a range

Ok! Figured it out! Woo!

Sub FillPuzzle()
Dim c As Range
Range("A1:D7").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Randomize
For Each c In Selection.Cells
c = Chr$(64 + Int(26 * Rnd + 1))
Next
Range("A1").Select
End Sub

Biff
-----Original Message-----
Thanks keepITcool !

Yes, that works. I think I can figure out just enough to
tweak it a little. Well, maybe not.....but I'll try it.

At what line of that macro would I add code to make the
selection of the MT(empty) cells automatic?

Thanks
Biff

-----Original Message-----
Biff,

I dont know what you mean with MT cells,
but does this work for you?

If fills the selected cells..


Sub FillPuzzle()
Dim c As Range
Randomize
For Each c In Selection.Cells
c = Chr$(64 + Int(26 * Rnd + 1))
Next
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Biff" wrote:

Hello Folks!

My VBA knowledge is slim to none so I need a little

help
with a macro.

I would like a macro that fills MT cells in a range

with
random uppercase letters A-Z. The cells will not

always
be
contiguous. I'm playing around with a word search

puzzle
and looking for a quick way to fill the MT cells.

Thanks for your help
Biff


.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Fill MT cells in a range

MT = empty



keepITcool wrote:

Biff,

I dont know what you mean with MT cells,
but does this work for you?

If fills the selected cells..

Sub FillPuzzle()
Dim c As Range
Randomize
For Each c In Selection.Cells
c = Chr$(64 + Int(26 * Rnd + 1))
Next
End Sub

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool

"Biff" wrote:

Hello Folks!

My VBA knowledge is slim to none so I need a little help
with a macro.

I would like a macro that fills MT cells in a range with
random uppercase letters A-Z. The cells will not always be
contiguous. I'm playing around with a word search puzzle
and looking for a quick way to fill the MT cells.

Thanks for your help
Biff


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Fill MT cells in a range

And using KeepItCool's code:

Option Explicit
Sub FillPuzzle2()

Dim c As Range
Dim myRng As Range

Set myRng = Nothing
On Error Resume Next
Set myRng = Intersect(Selection, _
Selection.Cells.SpecialCells(xlCellTypeBlanks))
On Error GoTo 0

if myrng is nothing then
msgbox "No empty cells in selection"
exit sub
end if

Randomize
For Each c In myRng.Cells
c = Chr$(64 + Int(26 * Rnd + 1))
Next c
End Sub

Select your range and run the code.



Biff wrote:

Hello Folks!

My VBA knowledge is slim to none so I need a little help
with a macro.

I would like a macro that fills MT cells in a range with
random uppercase letters A-Z. The cells will not always be
contiguous. I'm playing around with a word search puzzle
and looking for a quick way to fill the MT cells.

Thanks for your help
Biff


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Fill MT cells in a range

Thanks to both Dave and keepITcool!

Here's what I ended up with:

Sub FillPuzzle()
Dim c As Range
Application.ScreenUpdating = False
Range("Puzzle").Select
Selection.SpecialCells(xlCellTypeBlanks).Select

Randomize
For Each c In Selection.Cells
c = Chr$(64 + Int(26 * Rnd + 1))
Next
Range("A1").Select
Application.ScreenUpdating = True
End Sub

Works just fine. Now, if I could only figure a way to
automatically place the words in the puzzle !!! That one
might cause some brain damage though!

Biff

-----Original Message-----
And using KeepItCool's code:

Option Explicit
Sub FillPuzzle2()

Dim c As Range
Dim myRng As Range

Set myRng = Nothing
On Error Resume Next
Set myRng = Intersect(Selection, _
Selection.Cells.SpecialCells(xlCellTypeBlanks))
On Error GoTo 0

if myrng is nothing then
msgbox "No empty cells in selection"
exit sub
end if

Randomize
For Each c In myRng.Cells
c = Chr$(64 + Int(26 * Rnd + 1))
Next c
End Sub

Select your range and run the code.



Biff wrote:

Hello Folks!

My VBA knowledge is slim to none so I need a little help
with a macro.

I would like a macro that fills MT cells in a range with
random uppercase letters A-Z. The cells will not always

be
contiguous. I'm playing around with a word search puzzle
and looking for a quick way to fill the MT cells.

Thanks for your help
Biff


--

Dave Peterson

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I fill multiple cells in a row with single named range? Mike Patterson Excel Discussion (Misc queries) 1 September 24th 09 09:22 PM
Changing fill colour of cells in a range Paul Hyett[_2_] Excel Discussion (Misc queries) 8 July 14th 07 07:04 PM
Fill Blank cells in a range kevcar40 Excel Discussion (Misc queries) 2 March 27th 07 04:17 PM
automatically fill in a range of cells Maarten Excel Discussion (Misc queries) 1 April 29th 05 11:14 AM
Formula to count the cells in a range that have a fill color. Slainteva Excel Discussion (Misc queries) 2 January 19th 05 08:25 PM


All times are GMT +1. The time now is 08:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"