PC Review


Reply
Thread Tools Rate Thread

Automated Process that Updates Multiple Spreadsheets

 
 
Adel Pascaris
Guest
Posts: n/a
 
      19th Mar 2008
Hi all,



I created a VB module that transposes data in a spreadsheet. I need to use
this same code for many other spreadsheets. I was wondering if there is a
way to create an automated process that performs a mass update of all the
spreadsheets with the same worksheet name (for example sheet 2).



This is the code:



Option Explicit



Public Sub subTranspose()

' This subroutine copies the columns on the current worksheet and

' transposes them onto Sheet2.



Dim lngLastRow As Long

Dim strLastCol As String



lngLastRow = Cells.SpecialCells(xlCellTypeLastCell).Row



strLastCol =
funColumnLetter(Cells.SpecialCells(xlCellTypeLastCell).Column)



Range("A1:" & strLastCol & lngLastRow).Copy



Sheets("Sheet2").Range("A1:A1").PasteSpecial Paste:=xlPasteAll,
Transpose:=True

End Sub





Function funColumnLetter(intColumnNumber As Integer) As String

' This function translates column numbers into excel column letters.



If intColumnNumber > 26 Then



' 1st character: Subtract 1 to map the characters to 0-25,

' but you don't have to remap back to 1-26

' after the 'Int' operation since columns

' 1-26 have no prefix letter



' 2nd character: Subtract 1 to map the characters to 0-25,

' but then must remap back to 1-26 after

' the 'Mod' operation by adding 1 back in

' (included in the '65')



funColumnLetter = Chr(Int((intColumnNumber - 1) / 26) + 64) & _

Chr(((intColumnNumber - 1) Mod 26) + 65)

Else

' Columns A-Z

funColumnLetter = Chr(intColumnNumber + 64)

End If

End Function





Thanks in advance,



Adel


 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      19th Mar 2008
Hi Adel

See this page
http://www.rondebruin.nl/copy4.htm

Change the red code lines to your code


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Adel Pascaris" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi all,
>
>
>
> I created a VB module that transposes data in a spreadsheet. I need to use
> this same code for many other spreadsheets. I was wondering if there is a
> way to create an automated process that performs a mass update of all the
> spreadsheets with the same worksheet name (for example sheet 2).
>
>
>
> This is the code:
>
>
>
> Option Explicit
>
>
>
> Public Sub subTranspose()
>
> ' This subroutine copies the columns on the current worksheet and
>
> ' transposes them onto Sheet2.
>
>
>
> Dim lngLastRow As Long
>
> Dim strLastCol As String
>
>
>
> lngLastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
>
>
>
> strLastCol =
> funColumnLetter(Cells.SpecialCells(xlCellTypeLastCell).Column)
>
>
>
> Range("A1:" & strLastCol & lngLastRow).Copy
>
>
>
> Sheets("Sheet2").Range("A1:A1").PasteSpecial Paste:=xlPasteAll,
> Transpose:=True
>
> End Sub
>
>
>
>
>
> Function funColumnLetter(intColumnNumber As Integer) As String
>
> ' This function translates column numbers into excel column letters.
>
>
>
> If intColumnNumber > 26 Then
>
>
>
> ' 1st character: Subtract 1 to map the characters to 0-25,
>
> ' but you don't have to remap back to 1-26
>
> ' after the 'Int' operation since columns
>
> ' 1-26 have no prefix letter
>
>
>
> ' 2nd character: Subtract 1 to map the characters to 0-25,
>
> ' but then must remap back to 1-26 after
>
> ' the 'Mod' operation by adding 1 back in
>
> ' (included in the '65')
>
>
>
> funColumnLetter = Chr(Int((intColumnNumber - 1) / 26) + 64) & _
>
> Chr(((intColumnNumber - 1) Mod 26) + 65)
>
> Else
>
> ' Columns A-Z
>
> funColumnLetter = Chr(intColumnNumber + 64)
>
> End If
>
> End Function
>
>
>
>
>
> Thanks in advance,
>
>
>
> Adel
>
>

 
Reply With Quote
 
Adel Pascaris
Guest
Posts: n/a
 
      19th Mar 2008
Thanks Ron!

I'll give it a try.

Adel

"Ron de Bruin" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi Adel
> See this page
> http://www.rondebruin.nl/copy4.htm
>
> Change the red code lines to your code
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "Adel Pascaris" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi all,
>>
>>
>>
>> I created a VB module that transposes data in a spreadsheet. I need to
>> use this same code for many other spreadsheets. I was wondering if there
>> is a way to create an automated process that performs a mass update of
>> all the spreadsheets with the same worksheet name (for example sheet 2).
>>
>>
>>
>> This is the code:
>>
>>
>>
>> Option Explicit
>>
>>
>>
>> Public Sub subTranspose()
>>
>> ' This subroutine copies the columns on the current worksheet and
>>
>> ' transposes them onto Sheet2.
>>
>>
>>
>> Dim lngLastRow As Long
>>
>> Dim strLastCol As String
>>
>>
>>
>> lngLastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
>>
>>
>>
>> strLastCol =
>> funColumnLetter(Cells.SpecialCells(xlCellTypeLastCell).Column)
>>
>>
>>
>> Range("A1:" & strLastCol & lngLastRow).Copy
>>
>>
>>
>> Sheets("Sheet2").Range("A1:A1").PasteSpecial Paste:=xlPasteAll,
>> Transpose:=True
>>
>> End Sub
>>
>>
>>
>>
>>
>> Function funColumnLetter(intColumnNumber As Integer) As String
>>
>> ' This function translates column numbers into excel column letters.
>>
>>
>>
>> If intColumnNumber > 26 Then
>>
>>
>>
>> ' 1st character: Subtract 1 to map the characters to 0-25,
>>
>> ' but you don't have to remap back to 1-26
>>
>> ' after the 'Int' operation since columns
>>
>> ' 1-26 have no prefix letter
>>
>>
>>
>> ' 2nd character: Subtract 1 to map the characters to 0-25,
>>
>> ' but then must remap back to 1-26 after
>>
>> ' the 'Mod' operation by adding 1 back in
>>
>> ' (included in the '65')
>>
>>
>>
>> funColumnLetter = Chr(Int((intColumnNumber - 1) / 26) + 64) & _
>>
>> Chr(((intColumnNumber - 1) Mod 26) + 65)
>>
>> Else
>>
>> ' Columns A-Z
>>
>> funColumnLetter = Chr(intColumnNumber + 64)
>>
>> End If
>>
>> End Function
>>
>>
>>
>>
>>
>> Thanks in advance,
>>
>>
>>
>> Adel
>>


 
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
Automated Process that Updates all Spreadsheets in a Folder Adel Pascaris Microsoft Excel Programming 1 24th Mar 2008 03:27 PM
Daily automated process bmjnine@hotmail.com Microsoft Dot NET Framework 4 2nd Apr 2007 03:01 PM
Automated signature updates w/o using Windows Automated Updates =?Utf-8?B?Q3VydEI=?= Security Signatures 3 15th May 2006 01:31 AM
automated process (export) =?Utf-8?B?cnVkYXdn?= Microsoft Access VBA Modules 6 2nd May 2006 02:40 PM
automated process? =?Utf-8?B?REFOUkZYeg==?= Windows XP Networking 0 7th Feb 2005 05:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:27 AM.