Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Copy and Paste cells using VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
drings71@yahoo.com - 08 Jan 2007 21:54 GMT
Hi all!  I am a new poster and also a neophyte Visual Basic user.  I am
trying to create a macro that will cut the odd ranges in (B9:B649) to
(A9:A649).  There is data in the even ranges I will want to move up in
column B when I get the odd data moved to column A.  I've seen a lot of
options for ranges of consecutive cells but am lost when dealing with
random cells.  My last attempt was:

   Sub CutAndPaste()

   Dim X As Integer
   Dim Y As Integer
   Dim Sum As Integer

   Y = 1

   For X = 8 To 648

   Sum = X + Y
   Range("BSum").Cut Destination:=Range("ASum")

   Next
   End Sub

I was hoping I could use the Sum value as my row indicator but it
doesn't work.
I appreciate any input!
Dennis
Otto Moehrbach - 08 Jan 2007 23:00 GMT
One way:
Sub Test()
     Dim i As Range
     For Each i In Range("B9:B649")
           If i.Row Mod 2 <> 0 Then _
                 i.Cut i.Offset(, -1)
     Next i
End Sub
HTH  Otto
> Hi all!  I am a new poster and also a neophyte Visual Basic user.  I am
> trying to create a macro that will cut the odd ranges in (B9:B649) to
[quoted text clipped - 23 lines]
> I appreciate any input!
> Dennis
drings71@yahoo.com - 09 Jan 2007 14:50 GMT
Otto,

Thanks a lot!!!  That worked perfectly!

Dennis

> One way:
> Sub Test()
[quoted text clipped - 33 lines]
> > I appreciate any input!
> > Dennis
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.