VBA code for Tabs and various info

oldmandave

New Member
Joined
Mar 21, 2018
Messages
2
Hi

Im looking for a VBA/macro that will create tabs with numbers from C1 to BZ1
and then using the data in the master sheet populate the tabs as well as some fixed data and fields
I have invoice number C1:BZ1
Invoice description C2:BZ2

Product description in A3:A88
Product Code in B3:B88

and then in Cells C3 to BZ88 random numbers, theres a sum in C3:C89

I need some fixed words in A1:A5 and a few other randoms words in random cells
buts its all fixed on every tab

I know its a bit of and ask but need to know how to switch a few thisng round as well as different departments put in slightly different formats

THanks

and old man
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Code:
Sub AddSheets()
    Dim c As Long
    c = 3
    Dim address As String
    Dim s As Worksheet
    Do While True
        address = Replace(Cells(1, c).Address, "$", "")
        Set s = Sheets.Add
        s.Name = address
        If address = "BZ1" Then Exit Sub
        c = c + 1
    Loop
End Sub

try that (untested)

I just noticed you asked for more... this code will just add sheets named using those cell addresses... is that what you meant?? It also needs to be updated to pull info to those sheets
 
Last edited:
Upvote 0
start w this:

Code:
Sub BuildTabs()
Dim rng As Range, cel As Range


'make sheets
Set rng = Range("C1:BZ1")
 For Each cel In rng
    Sheets.Add
    ActiveSheet.Name = cel.Value
    Range("A1").Value = "Invoice:"
    Range("A2").Value = "Descr:"
 
    Range("b1").Value = cel.Value
    Range("b2").Value = cel.Offset(1, 0).Value
    
    Range("A3").Value = "words"
    Range("A4").Value = "words"
    Range("A5").Value = "words"
    
 Next   'sheet
 
Set cel = Nothing
Set rng = Nothing
End Sub
 
Upvote 0
Invoice: 9004914090049141900491429004914690049502900495039004950490049506900496619004966290049663900496649004966590049666
Descr: BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah
Project Management2134651235986.00 153.00
insurance brokers fees2134651235
electricity2134651235
gas2134651235
water2134651235 456.00
sewerage2134651235
telephony - rental & circuit charge (229)2134651235 84,759.00
telephony -calls2134651235
availability charge2134651235 56,415.00 456.00
availability charge- variation
2134651235 132.00231.00 486.00
rebate
2134651235 869,475.00
catering - afc element2134651235 456.00
catering - contract variations2134651235
catering2134651235589.00
cleaning (domestic services - afc element)2134651235
cleaning (domestic services)2134651235
pest control2134651235
2134651235
estates2134651235
linen & laundry2134651235986.00 50,707.33
portering - afc element2134651235258.00
heart centre portering2134651235
portering2134651235
portering other2134651235
waste2134651235
additional beds (winter contingency)2134651235 11,036.65
heart centre mgt fee2134651235
help desk variation2134651235
fm management & helpdesk2134651235
departmental provisions (additional catering)2134651235 5,962.00
net income
2134651235
Lifecycle charges2134651235
snack boxes (additional catering)
2134651235 2,589.00
switchboard - element
2134651235
2,819.000.00153.000.008,551.00920,314.3367,682.650.000.00942.00912.0084,759.000.000.00

<colgroup><col><col><col span="2"><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>


Heres a copy of the data im trying to get a tab for each of the columns of data
So on every tab a1 has invioce No and under it is data
on every tab a2 will have invoice descr and data under it
Like below

Invoice NoInvoice descProduct DescProduct CodeProduct SaleInvoice total
90049140BlahProject Management21346512359862819
catering2134651235589
linen & laundry2134651235986
portering - afc element2134651235258

<colgroup><col><col><col><col><col span="2"></colgroup><tbody>
</tbody>

Thats what Id like if its possible

oldman
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top