Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-02-2013, 02:23 PM
esco esco is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 32bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Novice
how can I cut and paste a line in page1 to page 2 by clicking a button?
 
Join Date: Nov 2011
Posts: 12
esco is on a distinguished road
Default how can I cut and paste a line in page1 to page 2 by clicking a button?

hello
I want to cut and paste a line in page 1 to page2 auto.
for example in a1 it says page 2, a2 xxxx, a3 xxxxx and in a4 there is a save button. when I click save button it should see a1 page 2 or maybe page 3, then it cut and paste all line to page 2 or page 3. but after paste to page 2 or 3, the line must go to next line I mean in order. sorry for bad english :/
thx
Reply With Quote
  #2  
Old 12-02-2013, 03:20 PM
BobBridges's Avatar
BobBridges BobBridges is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 64bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

If you have difficulties with English, I sympathize, esco, and I don't mind helping. But there are also some difficulties with the explanation. I have questions:

  1. "I want to cut and paste a line in page 1 to page2...." Is "page 1" the name of an Excel worksheet, or workbook, or what?
  2. "a1 it says page 2, a2 xxxx, a3 xxxxx and in a4 there is a save button." Ok, so "a1" through "a4" are cell references, A1 through A4. The contents of cell A1 say "page 2"; again, is that a worksheet name? The next two rows have something other data in them, and there's a button below that?
  3. "when I click save button it should see a1 page 2...." Do you mean that when you click on the button, Excel should display the worksheet named "page 2" (with cell A1 at the upper left)? Or that your program should go look at its contents for itself? Or what?
  4. "....should see a1 page 2 or maybe page 3...." This "or maybe" part will have to be defined more exactly, before we're through. But we can save that for later.
  5. "when I click save button it should see a1 page ?, then it cut and paste all line to page ?...." Ok, I'm more sure that these "pages" are worksheet names. (But not real sure; please confirm.) So when you click the Save button, you want something in Excel to cut all the lines from somewhere, and paste them to another worksheet. But which lines are "all lines", and where does it cut them from?
  6. "but after paste to page 2 or 3, the line must go to next line..." This I don't understand.
We can do this; we just need a really clear explanation.
Reply With Quote
  #3  
Old 12-03-2013, 07:16 AM
esco esco is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 32bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Novice
how can I cut and paste a line in page1 to page 2 by clicking a button?
 
Join Date: Nov 2011
Posts: 12
esco is on a distinguished road
Default

Sorry for poor explanation. Yes I mean worksheet."So when you click the Save button, you want something in Excel to cut all the lines from somewhere and paste them to another worksheet "yes true.
"Lines" I mean for example I write something to A2 A3 and A4.after clicking save button in A5 , it will cut A2 A3 and A4 and paste to another worksheet. But excel must see which worksheet writes in A1. İf in A1 it says worksheet 2, excel must cut and paste to worksheet 2
Reply With Quote
  #4  
Old 12-03-2013, 09:53 PM
BobBridges's Avatar
BobBridges BobBridges is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 64bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Ok, I think I understand. Tell me whether this is right:
Quote:
I have a worksheet name in A1, and some data in A2 and A3. In A4 is a button. I'd like the button to cause Excel to cut the data from A2 and A3, and paste it to cells in the worksheet named in A1.
Is that right so far? That doesn't sound too hard. But then you said that after the paste, "the line must go to next line I mean in order". What does that mean? By "the line", do you mean what's displayed to the user, or the data that's already been moved to another worksheet?
Reply With Quote
  #5  
Old 12-04-2013, 01:55 PM
esco esco is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 32bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Novice
how can I cut and paste a line in page1 to page 2 by clicking a button?
 
Join Date: Nov 2011
Posts: 12
esco is on a distinguished road
Default

yes it is right.
I mean after cut and paste worksheet 1 A2 and A3 to worksheet 2 A2 and A3, it should cut and paste my new data A2 and A3 in worksheet 1 to worksheet 2 next line B2 AND B3. this goes like this C3 C4 D3 D4 in worksheet 2...
I want excel cut and paste my new datas to other worksheets line by order
Reply With Quote
  #6  
Old 12-05-2013, 07:34 AM
BobBridges's Avatar
BobBridges BobBridges is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 64bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Ok, I think we're almost there. Let's try this new description:
Quote:
When I hit the Save button, I want it to do the following:
  1. Get the name of the target worksheet from A4
  2. Cut the data from A2 and A3.
  3. Go to the target worksheet.
  4. Find out which column is the next one available, and paste the data there. For example, if there's data already in column A through column E, then paste the data into F2 and F3.
How's that?
Reply With Quote
  #7  
Old 12-06-2013, 03:43 PM
esco esco is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 32bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Novice
how can I cut and paste a line in page1 to page 2 by clicking a button?
 
Join Date: Nov 2011
Posts: 12
esco is on a distinguished road
Default

All true only in first one "Get the name of the target worksheet from A4" not A4 from A1
Pls can you explain step by step how to make this?
Reply With Quote
  #8  
Old 12-07-2013, 12:05 AM
BobBridges's Avatar
BobBridges BobBridges is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 64bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Right, sorry, A4 is where the button is; I forgot. Yes, let's go over it step by step; but plan on it taking a while, because if you've never done a VBA program before it'll take you a while to learn the pieces.

So let's start here: You're about to create an Excel macro, a program in the VBA language. Do you know where to type in your statements? If you don't, we need to start there. If you do, here are the first few statements:
Code:
Sub Something() 'I don't care what you name it.
  Set wo = ThisWorkbook
  Set soFm = wo.Worksheets("Page1")
  snTo = soFm.Range("A1").Value
  MsgBox snTo
  End Sub
This very simple little program does the following:

1) Sets a variable called "wo" to point to the current workbook; that allows you to refer to it later.

2) Sets a variable called "soFm" to point to the worksheet in wo that is named "Page1". If that's not what you named the first worksheet, change it in the program. I named that variable "soFm" because the "so" prefix means "sheet object" to me, and "Fm" means "From"—that is, the sheet that the data is going to be transferred from.

3) Looks at Page1!A1, and puts the contents of that cell into a variable named snTo ("sheet name To"), which is the name of the worksheet where you want the data to be cut and pasted to.

4) Displays that name to you in a message window. By the time you're done writing this program, you don't want it to display the name of the sheet, you just want the program to transfer the data; but this is a good place to write that message and test the program so you can see that it's working so far. But don't worry, it's not done yet.

Try that, and tell me whether it's working right. If not, then we need to go back and figure out what's not going right.
Reply With Quote
  #9  
Old 12-07-2013, 03:45 PM
esco esco is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 32bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Novice
how can I cut and paste a line in page1 to page 2 by clicking a button?
 
Join Date: Nov 2011
Posts: 12
esco is on a distinguished road
Default

yes thx a lot. I did it :P and then?
Reply With Quote
  #10  
Old 12-07-2013, 09:45 PM
BobBridges's Avatar
BobBridges BobBridges is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 64bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Ok, let's see what's next...yes, picking up the two values in A2 and A3 and pasting them into the desired sheet. Still proceeding a few steps at a time, let's do this:
Code:
Sub Something() 'I don't care what you name it.
  Set wo = ThisWorkbook
  Set soFm = wo.Worksheets("Page1")

  snTo = soFm.Range("A1").Value 'collect the data from Page1
  v2 = soFm.Range("A2").Value
  v3 = soFm.Range("A3").Value

  set soTo = wo.Worksheets(snTo) 'paste the data in the target sheet
  soTo.Range("A2").Value = v2
  soTo.Range("A3").Value = v3
  End Sub
This still isn't finished, of course, but it takes the next step. The three statements marked "collect the data" take each of the values in A1, A2 and A3 and put them in three variables. The next statement sets soTo ("sheet object To") to point to whatever worksheet is named in A1. The last two statements put the values into A2 and A3 of the target sheet.

There are still several things wrong. For one thing, you want to cut the data from Page1, but this program is only copying it. And for another, in the new worksheet it's pasting the data in column A, but you need it to find the next free column to the right and paste it there (right?). But again, let's make sure this part is working right before we go on.

Also, you should feel free to rename the variables in this program to suit your own preferences, and to add or modify the comments so that they make sense to you rather than to me. Write them in your own language, of course (what is your language, anyway?), but also have them tell you more than I've chosen to say.

Before we go on to the next step, please a) confirm that your code is pasting the correct data into the correct worksheet (though not, yet, the correct column), and b) show me what your version of this program looks like so far.
Reply With Quote
  #11  
Old 12-09-2013, 01:13 PM
esco esco is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 32bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Novice
how can I cut and paste a line in page1 to page 2 by clicking a button?
 
Join Date: Nov 2011
Posts: 12
esco is on a distinguished road
Default

well it looks like did something but page2 A2 A3 are still empty.
my language is Turkish.
what does v2 v3 mean?
I know this and works.

Range("A1:A2").Select
Selection.Cut

Range("C4").Select
ActiveSheet.Paste
Reply With Quote
  #12  
Old 12-10-2013, 10:48 AM
BobBridges's Avatar
BobBridges BobBridges is offline how can I cut and paste a line in page1 to page 2 by clicking a button? Windows 7 64bit how can I cut and paste a line in page1 to page 2 by clicking a button? Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Sorry for the delay, esco.

I was hoping that your language would be one of the ones I can read, but Turkish isn't among them. Oh, well.

v2 and v3 are just the names of variables; in my program, I put the values that are in Page1!A2 and ...A3 into two variables, which I named v2 and v3, and then put them into A2 and A3 of the target worksheet. But you don't have to do it that way; you could do it directly, like this:
Code:
Sub Something() 'I don't care what you name it.
  Set wo = ThisWorkbook
  Set soFm = wo.Worksheets("Page1")

  ' Get the target worksheet name and paste the data.
  snTo = soFm.Range("A1").Value
  set soTo = wo.Worksheets(snTo)
  soTo.Range("A2").Value = soFm.Range("A2").Value
  soTo.Range("A3").Value = soFm.Range("A3").Value

  End Sub
I still need to see what your version of the program looks like. You showed me part of a program, but it's the program that you were using before you asked this question. I want to see the program that you started writing after I sent you some sample code. Remember? I showed you the beginning of a program, and I said "tell me whether it's working right". You answered "I did it :P". I want to see that program.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you prevent an empty line from appearing in the first line of a page? New Daddy Word 10 11-18-2013 07:01 AM
how can I cut and paste a line in page1 to page 2 by clicking a button? Find, copy and paste into a new page jperez84 Word VBA 24 09-20-2012 11:34 AM
how can I cut and paste a line in page1 to page 2 by clicking a button? How to paste into another app without line numbers? Moonf4 Word 1 04-18-2011 03:16 PM
First line on page is truncated (top of line) OwlCat1212 Word 0 02-14-2011 03:24 PM
How to cut and paste a graphic to a different page in word.? soooty Drawing and Graphics 1 08-12-2010 11:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft