PDA

View Full Version : [SOLVED] change row format to show 0 as first symbol



petroj02
10-20-2016, 05:04 AM
Hello all,
I have again a question about something and because I am sure you can help me there is my post.

I am working about sending automatic emails with pdf attachments converted from new Excel list, which is generated after some Kind of configuration... The configuration gives me basically sort of numbers and These numbers allways have to start with Zero and then follow six others numbers. These numbers are saved at original workbook at row with my own Format 0000000.

I know how to Change Format of row from General to my own 0000000 Format) in Excel, but I dont know the Syntax how to do that with vba since,I am able to convert sort of numbers from original to new workbook, but Zero as first Digit is hidden.

mikerickson
10-20-2016, 05:15 AM
Are you looking for the syntax


ActiveCell.NumberFormat = "0000000"

mana
10-20-2016, 05:17 AM
Selection.NumberFormat = "General"

mana
10-20-2016, 05:24 AM
Oh! my code is reverse action

petroj02
10-20-2016, 05:36 AM
to Mike This is exactly I am looking for I have tried this Syntax without " "...

to Mana For me with numberFormat as General is Zero hidden.

Thank you both for your fast Response... if you are interested there is a part of code for converting new Excel book to pdf


Sub saveToPDF(ByVal workbookName As String, sheetName As String)
Dim thedate As String
thedate = Format(Date, "DD/MM/YYYY")
Dim wb As Workbook
Set wb = Workbooks.Add
With wb
.Sheets("List1").Range("A1") = "Article list for orded Nr." & workbookName 'zápis názvu kusovníku
.Sheets("List1").Range("I1") = thedate 'zápis data pro hledání ve složkách
.Sheets("List1").Range("A:A").NumberFormat = "0000000"
Dim d As Object, c As Variant, i As Long, lr As Long ' kopírování unikátních ERP do nove vytvoreneho excel souboru
Set d = CreateObject("Scripting.Dictionary") ' _'
lr = ThisWorkbook.Sheets(sheetName).Cells(Rows.Count, 1).End(xlUp).Row ' _'
c = ThisWorkbook.Sheets(sheetName).Range("BK2:BK" & lr) ' _'
For i = 1 To UBound(c, 1) ' _'
d(c(i, 1)) = 1 ' _'
Next i ' _'
.Sheets("List1").Range("A2").Resize(d.Count) = Application.Transpose(d.Keys) ' _'
For i = 4 To 100 'zmena kazdeho druhe radku na sedy
.Sheets("List1").Cells(i, 1).EntireRow.Interior.ColorIndex = 15 ' _'
i = i + 1 ' _'
Next
.SaveAs "V:\CGC_DATA\Orders\" & thedate & "\" & workbookName 'ulozeni souboru pod novym nazvem (nazev odpovida objednavkovemu cislu)
.ExportAsFixedFormat Type:=xlTypePDF, Filename:="V:\CGC_DATA\Orders\" & thedate & "\" & workbookName, Quality:=xlQualityStandard, openAfterPublish:=False 'export do pdf
.Close 'zavreni nove vytvoreneho souboru
End With
End Sub