Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 



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 10:30 AM.


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