PC Review


Reply
Thread Tools Rate Thread

Copy and Paste cells using VB

 
 
drings71@yahoo.com
Guest
Posts: n/a
 
      8th Jan 2007
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

 
Reply With Quote
 
 
 
 
Otto Moehrbach
Guest
Posts: n/a
 
      8th Jan 2007
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
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
drings71@yahoo.com
Guest
Posts: n/a
 
      9th Jan 2007
Otto,

Thanks a lot!!! That worked perfectly!

Dennis

On Jan 8, 5:00 pm, "Otto Moehrbach" <ottokm...@comcast.net> wrote:
> 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<dring...@yahoo.com> wrote in messagenews:(E-Mail Removed)...
>
> > 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy several nonajacent cells and paste to ajacent cells in one row Bluejay Microsoft Excel Programming 7 19th May 2011 10:27 PM
Copy and paste versus copy and insert copied cells =?Utf-8?B?QWxhbmE=?= Microsoft Excel New Users 1 28th Sep 2007 08:58 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values =?Utf-8?B?RGVubmlz?= Microsoft Excel Misc 10 2nd Mar 2006 10:47 PM
Re: Copy/Paste in Excel prints highlighted cells and does not paste Debra Dalgleish Microsoft Excel Misc 0 30th Jul 2003 11:59 PM
Re: Copy/Paste in Excel prints highlighted cells and does not paste Dave Peterson Microsoft Excel Misc 0 30th Jul 2003 11:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:10 AM.