Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Clear Contents

Hello from Steved

Below is my attempt to clear contents from Colunmn J:J

my issue is that it clears the column first before combining the Col I and
Col J contents What is required please to change this Thankyou

Sub Trythis()
Dim lastcell As Long
Dim i As Long
lastcell = Cells(Rows.Count, "I").End(xlUp).Row
For i = 1 To lastcell
'combine Column I and J
Range("I" & i).Value = Range("I" & i).Value & " " & _
Range("I" & i).Offset(0, 1).Value
'clear column J value
Columns("J:J").Select
Selection.ClearContents
Next
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Clear Contents

You have your Next in the wrong place. Put it before the Columns("J").Select

"Steved" wrote:

Hello from Steved

Below is my attempt to clear contents from Colunmns(" J:J")
my issue is that it clears the column first before combining the Col I and
Col J contents What is required please to change this Thankyou

Sub Trythis()
Dim lastcell As Long
Dim i As Long
lastcell = Cells(Rows.Count, "I").End(xlUp).Row
For i = 1 To lastcell
'combine Column I and J
Range("I" & i).Value = Range("I" & i).Value & " " & _
Range("I" & i).Offset(0, 1).Value
'clear column J value
Columns("J:J").Select
Selection.ClearContents
Next
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Clear Contents

hi
you are clearing the entire column J before the loop finishes. don't do that.
change....
Columns("J:J").Select
Selection.ClearContents
to....
Range("I" & i).Offset(0, 1).ClearContents

this way the contents of column will be cleared as the loop runs, not all at
once.

regards
FSt1

"Steved" wrote:

Hello from Steved

Below is my attempt to clear contents from Colunmn J:J

my issue is that it clears the column first before combining the Col I and
Col J contents What is required please to change this Thankyou

Sub Trythis()
Dim lastcell As Long
Dim i As Long
lastcell = Cells(Rows.Count, "I").End(xlUp).Row
For i = 1 To lastcell
'combine Column I and J
Range("I" & i).Value = Range("I" & i).Value & " " & _
Range("I" & i).Offset(0, 1).Value
'clear column J value
Columns("J:J").Select
Selection.ClearContents
Next
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Clear Contents

Thankyou.

"JLGWhiz" wrote:

You have your Next in the wrong place. Put it before the Columns("J").Select

"Steved" wrote:

Hello from Steved

Below is my attempt to clear contents from Colunmns(" J:J")
my issue is that it clears the column first before combining the Col I and
Col J contents What is required please to change this Thankyou

Sub Trythis()
Dim lastcell As Long
Dim i As Long
lastcell = Cells(Rows.Count, "I").End(xlUp).Row
For i = 1 To lastcell
'combine Column I and J
Range("I" & i).Value = Range("I" & i).Value & " " & _
Range("I" & i).Offset(0, 1).Value
'clear column J value
Columns("J:J").Select
Selection.ClearContents
Next
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Clear Contents

Thankyou.

"FSt1" wrote:

hi
you are clearing the entire column J before the loop finishes. don't do that.
change....
Columns("J:J").Select
Selection.ClearContents
to....
Range("I" & i).Offset(0, 1).ClearContents

this way the contents of column will be cleared as the loop runs, not all at
once.

regards
FSt1

"Steved" wrote:

Hello from Steved

Below is my attempt to clear contents from Colunmn J:J

my issue is that it clears the column first before combining the Col I and
Col J contents What is required please to change this Thankyou

Sub Trythis()
Dim lastcell As Long
Dim i As Long
lastcell = Cells(Rows.Count, "I").End(xlUp).Row
For i = 1 To lastcell
'combine Column I and J
Range("I" & i).Value = Range("I" & i).Value & " " & _
Range("I" & i).Offset(0, 1).Value
'clear column J value
Columns("J:J").Select
Selection.ClearContents
Next
End Sub


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
Clear Contents gibbylinks Setting up and Configuration of Excel 5 October 12th 09 05:04 PM
Clear Contents Secret Squirrel Excel Discussion (Misc queries) 1 February 3rd 09 12:37 AM
Clear Contents Richard Excel Programming 5 September 11th 07 01:34 PM
Macro to clear range contents when cell contents are changed by us Steve E Excel Programming 12 February 22nd 07 09:09 PM
Clear contents if x is not in the row Mighvik Excel Programming 1 October 5th 04 08:14 PM


All times are GMT +1. The time now is 01:46 AM.

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"