VBA Code to fill text + series

shaikhstonevilla

New Member
Joined
Dec 5, 2012
Messages
23
Hi,

I have the data as under.

TvXv36NKlS8GzVFBQuBa0mAtmu0WLyQW9rv4f93dVWpuXViwAAAAASUVORK5CYII=



I will enter some text in B15 cell and i will enter serial number in B16 cell manually.

So what i want is when i run a macro, it will automatically create a invoice number as per B column.

Please help me with macro.


Thank you,

Shaikhstonevilla
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Re: VBA Code Help to fill text + series

Hi,
with everything in VBA many different ways to achive things.
Firstly you could use a formula in B17 =Contatenate(B15," ",B16)
So your chosen invoice Nr: is in "B17" or where ever you like to have it.

Then you can refer to that range via code. But I would use Properties to do so .. Property Let and Get Statements for this.

in the module put following


Code:
Option Explicit

Private m_Invoice as variant

Public Property Let Invoice(varInvoice as Variant)
m_Invoice=varInvoice

End Property


Public Property Get Invoice()as Variant
Invoice=m_Invoice
End Property

Code:
 
Upvote 0
Re: VBA Code Help to fill text + series

Sorry for this message I had to leave in a hurry..

I'll post it again clearer..


Code:
Private m_Invoice As Variant
'

Public Property Let Invoice(varInvoice As Variant)
    m_Invoice = varInvoice
End Property
Public Property Get Invoice() As Variant
    Invoice = m_Invoice
End Property

Sub TestMyInvoice()
    Dim wksThis As Worksheet
    
    Set wksThis = Worksheets("Tabelle2")        'Change to suit
    
    Invoice = wksThis.Range("B17")              'Here Invoice Property Let
    
    
    'If you like to get your Invoice Nr
    
    wksThis.Range("A1").Value = Invoice         'Here the Invoice Property Get...
    
   
    Debug.Print Invoice
    
End Sub

HTH
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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