Wikiposts
Search

Notices
Computer/Internet Issues & Troubleshooting Anyone with questions about the terribly complex world of computers or the internet should try here. NOT FOR REPORTING ISSUES WITH PPRuNe FORUMS! Please use the subforum "PPRuNe Problems or Queries."

More vba help please

Thread Tools
 
Search this Thread
 
Old 13th June 2012 | 20:57
  #1 (permalink)  
Thread Starter
Per Ardua ad Astraeus
 
Joined: Mar 2000
Posts: 18,575
Likes: 4
From: UK
More vba help please

I have been chuntering away happily now for months developing a prog, but need some aid now if poss. Google is coming up short.

I have a workbook "PPrune.xls" which has 3 worksheets, 1, 2 and 3. I wish to be able to select which of the three (or all) I save to a new workbook 'Danny.xls", 1,2 and 3. I'm happy with the selection, and can save the first sheet as sheet 1 - it is adding the next 1 or 2 I am stumped on.
BOAC is offline  
Reply
Old 14th June 2012 | 14:54
  #2 (permalink)  
 
Joined: Jan 2012
Posts: 2,173
Likes: 0
From: .
I don't have an answer - I know nowt about spreadsheets, but I suspect the lack if response is that people don't understand the question

What are you actually trying to do - simple resave a spreadsheet under another name? Or are these spreadsheets outputs from a program and you're trying to redirect the outputs to another format? Or what?
Milo Minderbinder is offline  
Reply
Old 14th June 2012 | 15:41
  #3 (permalink)  
Thread Starter
Per Ardua ad Astraeus
 
Joined: Mar 2000
Posts: 18,575
Likes: 4
From: UK
"What are you actually trying to do - simple resave a spreadsheet under another name? Or are these spreadsheets outputs from a program and you're trying to redirect the outputs to another format? Or what? " - I'm not sure where you got that from, but as you say you don't understand spreadsheets.

I thought "I have a workbook "PPrune.xls" which has 3 worksheets, 1, 2 and 3. I wish to be able to select which of the three (or all) I save to a new workbook 'Danny.xls", 1,2 and 3. I'm happy with the selection, and can save the first sheet as sheet 1 - it is adding the next 1 or 2 I am stumped on."

was pretty straightforward to anyone who understands Excel/Libre-Office programming, and I suspect it is. Hopefully someone will come along one day.
BOAC is offline  
Reply
Old 14th June 2012 | 16:17
  #4 (permalink)  
 
Joined: Jan 2012
Posts: 2,173
Likes: 0
From: .
the comment "I have been chuntering away happily now for months developing a prog" is likely to throw a few people in a false direction then

The assumption would be that the spreadsheets are outputs from some other program that you're working on...
Milo Minderbinder is offline  
Reply
Old 14th June 2012 | 16:22
  #5 (permalink)  
Thread Starter
Per Ardua ad Astraeus
 
Joined: Mar 2000
Posts: 18,575
Likes: 4
From: UK
The assumption would be that the spreadsheets are outputs from THIS program that you're working on.
would be correct. You may not realise, but a 'programme' and a 'worksheet' (although the VBA code is contained in a worksheet just to confuse you.....that's how VBA works, VB is slightly different) are two separate animals.
BOAC is offline  
Reply
Old 14th June 2012 | 17:27
  #6 (permalink)  
 
Joined: Jan 2012
Posts: 2,173
Likes: 0
From: .
I'm well aware they are and so are most of the readers - and thats whats going to confuse.
Milo Minderbinder is offline  
Reply
Old 14th June 2012 | 18:16
  #7 (permalink)  
Thread Starter
Per Ardua ad Astraeus
 
Joined: Mar 2000
Posts: 18,575
Likes: 4
From: UK
It will not confuse those who understand.
BOAC is offline  
Reply
Old 15th June 2012 | 01:46
  #8 (permalink)  
25 Anniversary
 
Joined: May 2001
Posts: 1,909
Likes: 24
From: England
I'm not being funny, but if all else fails you could always try a Mouse/Keyboard input recorder of some sort to do the job.
Superpilot is offline  
Reply
Old 15th June 2012 | 07:04
  #9 (permalink)  
Thread Starter
Per Ardua ad Astraeus
 
Joined: Mar 2000
Posts: 18,575
Likes: 4
From: UK
No sp, that's a good suggestion, but I am well past that stage. I need someone with a good knowledge of VBA who is prepared to help here (by PM/email).

Since you ask, the routine works fine as a keyboard recorded macro but will not run correctly in the main programme.
BOAC is offline  
Reply
Old 15th June 2012 | 17:03
  #10 (permalink)  
 
Joined: Jan 2012
Posts: 2,173
Likes: 0
From: .
Try asking here

Visual Basic for Applications (VBA) Forum

or here

Free Excel\VBA Help Forum
Milo Minderbinder is offline  
Reply
Old 15th June 2012 | 18:05
  #11 (permalink)  
Thread Starter
Per Ardua ad Astraeus
 
Joined: Mar 2000
Posts: 18,575
Likes: 4
From: UK
Yes, Milo, it is on the list. I am already 'registered from some years back, but I am a bit busy and I had hoped for a quick fix here.

Last edited by BOAC; 15th June 2012 at 18:05.
BOAC is offline  
Reply
Old 16th June 2012 | 22:39
  #12 (permalink)  
20 Anniversary
 
Joined: Mar 2003
Posts: 195
Likes: 2
From: Aus
BOAC,

Google search bought up this

MSlink

Sub Mover3()
Dim BkName As String
Dim NumSht As Integer
Dim BegSht As Integer

'Starts with second sheet - replace with index number of starting sheet.
BegSht = 2
'Moves two sheets - replace with number of sheets to move.
NumSht = 2
BkName = ActiveWorkbook.Name

For x = 1 To NumSht
'Moves second sheet in source to front of designated workbook.
Workbooks(BkName).Sheets(BegSht).Move _
Before : = Workbooks("Test.xls").Sheets(1)
'In each loop, the next sheet in line becomes indexed as number 2.
'Replace Test.xls with the full name of the target workbook you want.
Next
End Sub
That should give you some ideas

Max
Agent86 is online now  
Reply
Old 17th June 2012 | 07:06
  #13 (permalink)  
Thread Starter
Per Ardua ad Astraeus
 
Joined: Mar 2000
Posts: 18,575
Likes: 4
From: UK
Good find, thanks Agent. I'll give that a go. Since the intitial responses I have been looking at a different approach, so with thanks to all for the help I will let this thread die..
BOAC is offline  
Reply

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 Off
Pingbacks are Off
Refbacks are Off



Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service

Copyright © 2026 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.