Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Return the column of the next empty cell

Hey guys I think this is a simple one. I have Range
A4:Z4. There can be as many as 26 total values in this
range (1 value per cell). There are currently 21 values
in Row4, which means currently the last value is in
ColumnU. The next data I enter needs to go in ColumnV
(Cell V4).

Heres my question:
What would the formula be to return the next empty Column
in Row4? For instance, in this case the formula would
need to return the value "V" because the next empty column
in Range A4:Z4 is columnV.

Todd Huttenstine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Return the column of the next empty cell

Sub FindColumn()
Dim intCol As Integer
Dim strCol As String
intCol = Range("A4").End(xlToRight).Offset(0, 1).Column
strCol = ConvertNumberToLetter(intCol)
MsgBox strCol
End Sub

Function ConvertNumberToLetter(intNum As Integer) As String
'' Convert a column number to letter.
ConvertNumberToLetter = _
Left(Columns(intNum).Address(False, False), _
2 + 1 * (Columns(intNum).Column < 27))
End Function

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

Hey guys I think this is a simple one. I have Range
A4:Z4. There can be as many as 26 total values in this
range (1 value per cell). There are currently 21 values
in Row4, which means currently the last value is in
ColumnU. The next data I enter needs to go in ColumnV
(Cell V4).

Heres my question:
What would the formula be to return the next empty Column
in Row4? For instance, in this case the formula would
need to return the value "V" because the next empty column
in Range A4:Z4 is columnV.

Todd Huttenstine


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Return the column of the next empty cell

Beautiful! Thank you, it works perfect.

Todd



-----Original Message-----
Sub FindColumn()
Dim intCol As Integer
Dim strCol As String
intCol = Range("A4").End(xlToRight).Offset(0,

1).Column
strCol = ConvertNumberToLetter(intCol)
MsgBox strCol
End Sub

Function ConvertNumberToLetter(intNum As Integer) As

String
'' Convert a column number to letter.
ConvertNumberToLetter = _
Left(Columns(intNum).Address(False, False), _
2 + 1 * (Columns(intNum).Column < 27))
End Function

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
----------------------------------------------------------

----------------------------------------------------
Be advised to back up your WorkBook before attempting to

make changes.
----------------------------------------------------------

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

Hey guys I think this is a simple one. I have Range
A4:Z4. There can be as many as 26 total values in this
range (1 value per cell). There are currently 21 values
in Row4, which means currently the last value is in
ColumnU. The next data I enter needs to go in ColumnV
(Cell V4).

Heres my question:
What would the formula be to return the next empty

Column
in Row4? For instance, in this case the formula would
need to return the value "V" because the next empty

column
in Range A4:Z4 is columnV.

Todd Huttenstine


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Return the column of the next empty cell

Hi

Can you tell me about the logic behind this formula cause I am not seeing it
Left(Columns(intNum).Address(False, False), _
2 + 1 * (Columns(intNum).Column < 27))




"Todd Huttenstine" wrote in message ...
Hey guys I think this is a simple one. I have Range
A4:Z4. There can be as many as 26 total values in this
range (1 value per cell). There are currently 21 values
in Row4, which means currently the last value is in
ColumnU. The next data I enter needs to go in ColumnV
(Cell V4).

Heres my question:
What would the formula be to return the next empty Column
in Row4? For instance, in this case the formula would
need to return the value "V" because the next empty column
in Range A4:Z4 is columnV.

Todd Huttenstine

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
Need formula to return first value in a cell that is non empty Kasper Excel Discussion (Misc queries) 2 January 30th 09 12:12 PM
return empty string value if cell is blank Nat Excel Discussion (Misc queries) 2 April 1st 08 08:55 PM
Return an empty or blank cell value? Troymello Excel Worksheet Functions 0 March 3rd 06 05:19 PM
return an EMPTY cell in an IF formula JJN Excel Discussion (Misc queries) 3 February 10th 06 04:14 PM
Return an empty cell Mike D. Excel Discussion (Misc queries) 2 January 3rd 06 06:27 PM


All times are GMT +1. The time now is 12:30 PM.

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

About Us

"It's about Microsoft Excel"