Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Need code for simple IF-Then

I'm trying to insert an "X" in any empty cells in Row 7 for columns C,D
E & F. I'm formatting all the cells in a large block (columns A - R,
with a varied number of rows), but the results using CurrentRegion
won't extend out past columns C - F when they are empty, which they
usually are. I could include a macro to insert the X's, but sometimes
these columns actually DO have data in them, and I don't want to
overwrite any data. THANKS

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need code for simple IF-Then


Hello excelnut1954,

Here is simple macro to fill in the empty spaces. Copy and Paste this
code into a VBA project module.


Code:
--------------------
Public Sub XFill()
Dim C As Long

For C = 3 to 6
If Cells(7, C).Value < "" Then
Cells(7, C).Value = "X"
End If
Next C

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=483342

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need code for simple IF-Then


Hello excelnut1954,

Here is simple macro to fill in the empty spaces. Copy and Paste this
code into a VBA project module.


Code:
--------------------
Public Sub XFill()
Dim C As Long

For C = 3 to 6
If Cells(7, C).Value = "" Then
Cells(7, C).Value = "X"
End If
Next C

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=483342

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Need code for simple IF-Then

Excellent!!! I really appreaciate this. I've taken an in-house class
on VBA where I work, but of course, that was just the start. I got an
800+ page book on VBA, but it barely touches on the If-then coding.
I've learned alot just playing around with everything, so I can do
quite alot now. But, I really needed this to complete a project of
automating a spreadsheet I designed here before, so others can update
daily info without being an expert in Excel.
Thanks for getting me over this hurdle, and for the quick response.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Need code for simple IF-Then

Hi. Just another option:

On Error Resume Next
[C7:F7].SpecialCells(xlCellTypeBlanks) = "X"

HTH
--
Dana DeLouis
Win XP & Office 2003


"excelnut1954" wrote in message
oups.com...
Excellent!!! I really appreaciate this. I've taken an in-house class
on VBA where I work, but of course, that was just the start. I got an
800+ page book on VBA, but it barely touches on the If-then coding.
I've learned alot just playing around with everything, so I can do
quite alot now. But, I really needed this to complete a project of
automating a spreadsheet I designed here before, so others can update
daily info without being an expert in Excel.
Thanks for getting me over this hurdle, and for the quick response.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Need code for simple IF-Then

Thanks Dana. I'll have to check and see how this works different than
what Leith gave me earlier. They both seem to work for that I'm doing
in this project.
Thanks again.

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
Help with some simple code Angeline Excel Discussion (Misc queries) 4 October 12th 06 09:06 AM
Simple Code, I think... [email protected] Excel Worksheet Functions 1 August 2nd 06 08:09 PM
Want a simple VBA code. madhu Excel Programming 2 February 1st 05 01:46 PM
need a simple code Peter McCaul Excel Programming 1 August 11th 04 08:13 PM
simple code gavmer[_5_] Excel Programming 4 May 19th 04 03:32 AM


All times are GMT +1. The time now is 04:35 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"