LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Loop Statement through If Not IsEmpty Then Paste into Destinat

I see that Mike H gave you a nice solution also. Thanks for the feedback.
Good luck with your project.

"Dandelo" wrote:

Thank you, JLatham. Here's what I entered into the tab and it worked!

Sub LathamCopyit()

Dim colORange As Range
Dim anyColOCell As Range

Set colORange = ActiveSheet.Range("O2:" & _
ActiveSheet.Range("O" & Rows.Count).End(xlUp).Address)
For Each anyColOCell In colORange
If Not IsEmpty(anyColOCell) Then
'copy from column O to column E (-10 columns)
anyColOCell.Offset(0, -10) = anyColOCell
End If
Next
Set colORange = Nothing
End Sub


--
Thank you so much for your help!


"JLatham" wrote:

There's a difference between being empty and having a zero length string ( ""
) in a cell. An empty cell truly has nothing in it - no value, no formula.

I would do this with your loop, beginning with the Dim i As Integer statement

Dim colORange As Range
Dim anyColOCell As Range

Set colORange = ActiveSheet.Range("O2:" & _
ActiveSheet.Range("O" & Rows.Count).End(xlUP).Address)
For Each anyColOCell In colORange
If Not IsEmpty(anyColOCell) Then
'copy from column O to column E (-10 columns)
anyColOCell.Offset(0, -10) = anyColOCell
End If
Next
Set colORange = Nothing



"Dandelo" wrote:

Trying to write macro that will loop through cells in Column"O" and If Not
IsEmpty paste the Value in Column"O" into Column"E" of the same row number.
Any thoughts? Any help is greatly appreciated.

I have some examples I've picked up from the MVPs in this group, but I can't
seem to put it together. (I've also looked at Ron DeBruin's site which is
excellent, but I still need help).
I use variations of these in current macros (but I can't remember which
posts I got these from to give the author credit):

Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
.Range("A2").Select
Selection.AutoFill _
Destination:=Range("A2:A" & LastRow), Type:=xlFillDefault
End With

Dim i As Integer

i = 2
For i = 2 To Cells(Rows.Count, "B").End(xlUp).Row
If Cells(i, "I").Value = "" Then
Cells(i, "I").Value = Cells(i - 1, "I").Value
End If
Next i
--
Thank you so much for your help!

 
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
Form If IsEmpty Syntax Gizmo Excel Discussion (Misc queries) 4 May 25th 08 03:50 PM
Paste names from a source workbook to a destination kerfloo Excel Discussion (Misc queries) 0 January 31st 08 04:55 PM
paste options - set default to match destination formatting Amy Excel Discussion (Misc queries) 1 June 20th 06 07:39 AM
HDI change paste options default to "Match Destination Formatting HAT3 Setting up and Configuration of Excel 0 May 4th 06 02:51 PM
If statement - Loop? George Excel Discussion (Misc queries) 1 March 14th 06 07:06 AM


All times are GMT +1. The time now is 02:18 AM.

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"