Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Need Some Help With A Simple Cut & Paste Macro

  • Please log in to reply
No replies to this topic

#1 kimgeni


  • Members
  • 104 posts
  • Gender:Male
  • Location:NO
  • Local time:08:27 AM

Posted 16 June 2007 - 06:53 AM


Im collecting some data in a spreadsheet in Excel. Because of the way the data are listed in the web pages Im copying from, the data end up underneath each other like this
I want to cut and paste number 2, 4 and so on, so that they end up in cells in the same row:
1 2
3 4
I've never programmed before, however I've got a book with one chapter about programming, so I've tried to make a macro.

Innstartcelle is the name of the start cell for the indata, UtStartcelle the cell I want to cut the data to. I named the cells using insert-name-define. The cells I want to connect are in every other row, so I've added 2 in the end. I wrote "stopp" at the end of the data list. When I try to run the macro I get the message object required.

Sub CutAndPaste()

innRekke = Range("InnStartcelle").Row
innKol = Range("InnStartcelle").Column
utRekke = Range("UtStartcelle").Row
utKol = Range("UtStartcelle").Column

songname = Cells(innRekke, innKol).Value
newSongname = Cells(utRekke, utKol).Value

Do While songname <> "Stopp"

songname.Cut (newSongname)

'Prepar next
innRekke = innRekke + 2
utRekke = utRekke + 2


End Sub

I hope Im not to far away. I also want to delete the entire row (the one I cuted from) after cuting.

Do you know a web page I can use to learn more about macros? Or perhaps a book I should read?


Edited by kimgeni, 16 June 2007 - 07:16 AM.

BC AdBot (Login to Remove)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users