Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default If column B not empty, value in column A = L

Hi there,
I'm trying to maybe modifying this code:
Dim i As Long
On Error Resume Next
For i = 1 To ActiveSheet.UsedRange.Rows.Count( Maybe change this to From
Range B5 to last cell where there is data)
If Cells(i, "B") = "" Then Change This Whats the syntax for Not empty?
Cells(i, "A").Value = "L"
End If
Next
So basically if there is data in Column B5, then put L in Column A.

Please advise
Thanks for any help
Juan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default If column B not empty, value in column A = L

How about:

Sub gsnu()
dim r as range

Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1

For i = 5 To nLastRow
If IsEmpty(Cells(i, 2).Value) Then
Else
Cells(i, 1).Value = "L"
End If
Next
End Sub

--
Gary's Student


"Juan" wrote:

Hi there,
I'm trying to maybe modifying this code:
Dim i As Long
On Error Resume Next
For i = 1 To ActiveSheet.UsedRange.Rows.Count( Maybe change this to From
Range B5 to last cell where there is data)
If Cells(i, "B") = "" Then Change This Whats the syntax for Not empty?
Cells(i, "A").Value = "L"
End If
Next
So basically if there is data in Column B5, then put L in Column A.

Please advise
Thanks for any help
Juan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default If column B not empty, value in column A = L

Hello Gary and TOm,
thanks alot for the quick reply.
Gary, I tried yours and seems to work perfectly. Tom yours works but puts an
L in range I dont' want. Just want From B5. I have data in B4 and B3, so your
code will put in A3 and A4 and L, which I don't want this to do. But i should
be able to work around this.

So wanted to Thank both of you for the help.

Have a great weekend.

Juan

"Gary''s Student" wrote:

How about:

Sub gsnu()
dim r as range

Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1

For i = 5 To nLastRow
If IsEmpty(Cells(i, 2).Value) Then
Else
Cells(i, 1).Value = "L"
End If
Next
End Sub

--
Gary's Student


"Juan" wrote:

Hi there,
I'm trying to maybe modifying this code:
Dim i As Long
On Error Resume Next
For i = 1 To ActiveSheet.UsedRange.Rows.Count( Maybe change this to From
Range B5 to last cell where there is data)
If Cells(i, "B") = "" Then Change This Whats the syntax for Not empty?
Cells(i, "A").Value = "L"
End If
Next
So basically if there is data in Column B5, then put L in Column A.

Please advise
Thanks for any help
Juan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default If column B not empty, value in column A = L

Guess I didn't read all the specifications closely enough
Sub AAA()
Dim rng As Range
Set rng = Range(Cells(5, 2), _
Cells(Rows.Count, 2).End(xlUp))
rng.Offset(0, -1).Formula = _
"=if(B1<"""",""L"",na())"
rng.Offset(0, -1).Formula = _
rng.Offset(0, -1).Value
On Error Resume Next
rng.Offset(0, -1).SpecialCells( _
xlConstants, xlErrors).ClearContents
On Error GoTo 0

End Sub

--
Regards,
Tom Ogilvy

"Juan" wrote:

Hello Gary and TOm,
thanks alot for the quick reply.
Gary, I tried yours and seems to work perfectly. Tom yours works but puts an
L in range I dont' want. Just want From B5. I have data in B4 and B3, so your
code will put in A3 and A4 and L, which I don't want this to do. But i should
be able to work around this.

So wanted to Thank both of you for the help.

Have a great weekend.

Juan

"Gary''s Student" wrote:

How about:

Sub gsnu()
dim r as range

Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1

For i = 5 To nLastRow
If IsEmpty(Cells(i, 2).Value) Then
Else
Cells(i, 1).Value = "L"
End If
Next
End Sub

--
Gary's Student


"Juan" wrote:

Hi there,
I'm trying to maybe modifying this code:
Dim i As Long
On Error Resume Next
For i = 1 To ActiveSheet.UsedRange.Rows.Count( Maybe change this to From
Range B5 to last cell where there is data)
If Cells(i, "B") = "" Then Change This Whats the syntax for Not empty?
Cells(i, "A").Value = "L"
End If
Next
So basically if there is data in Column B5, then put L in Column A.

Please advise
Thanks for any help
Juan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default If column B not empty, value in column A = L

Sub AAA()
Dim rng As Range
Set rng = Range(Cells(1, 2), _
Cells(Rows.Count, 2).End(xlUp))
rng.Offset(0, -1).Formula = _
"=if(B1<"""",""L"",na())"
rng.Offset(0, -1).Formula = _
rng.Offset(0, -1).Value
On Error Resume Next
rng.Offset(0, -1).SpecialCells( _
xlConstants, xlErrors).ClearContents
On Error GoTo 0

End Sub

puts L where there is data in column B. I believe that is what you
described.

--
Regards,
Tom Ogilvy


"Juan" wrote:

Hi there,
I'm trying to maybe modifying this code:
Dim i As Long
On Error Resume Next
For i = 1 To ActiveSheet.UsedRange.Rows.Count( Maybe change this to From
Range B5 to last cell where there is data)
If Cells(i, "B") = "" Then Change This Whats the syntax for Not empty?
Cells(i, "A").Value = "L"
End If
Next
So basically if there is data in Column B5, then put L in Column A.

Please advise
Thanks for any help
Juan



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
Looping until empty column theguz[_3_] Excel Programming 2 August 4th 05 11:29 PM
Looping until empty column theguz Excel Discussion (Misc queries) 1 August 4th 05 07:04 PM
Get next empty Column? James[_30_] Excel Programming 3 September 17th 04 11:53 PM
Next Empty Column in Row scain2004[_20_] Excel Programming 1 June 16th 04 07:20 AM
delete empty column in VBA Lillian[_5_] Excel Programming 10 November 17th 03 05:07 AM


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