Notes in Hindi

Fonts & Backgrounds in Hindi

Makhanlal Chaturvedi University / BCA / VBA programming

Fonts and Backgrounds in Excel VBA in Hindi

Fonts and Backgrounds in Excel VBA in Hindi

Using Font Property in Excel VBA Cells in Hindi

जब हम Excel VBA (Visual Basic for Applications) का उपयोग करते हैं, तो हम Excel की cells को प्रोग्रामिंग के ज़रिए control कर सकते हैं। Excel VBA में Font Property का उपयोग करके हम किसी भी cell की लिखावट को customize कर सकते हैं, जैसे – font का नाम, size, bold, italic, underline आदि।

  • Font.Name: इससे आप font का नाम सेट कर सकते हैं जैसे कि Arial, Calibri आदि।
  • Font.Size: यह font का आकार तय करता है।
  • Font.Bold: इससे font bold हो जाता है।
  • Font.Italic: इससे font italic हो जाता है।
  • Font.Underline: इससे underline लगाया जाता है।
  • Font.Color: इससे font का रंग तय किया जाता है।

नीचे एक उदाहरण दिया गया है:

Sub SetFontStyle()
  Range("A1").Font.Name = "Arial"
  Range("A1").Font.Size = 14
  Range("A1").Font.Bold = True
  Range("A1").Font.Italic = True
  Range("A1").Font.Underline = xlUnderlineStyleSingle
  Range("A1").Font.Color = RGB(255, 0, 0)
End Sub

इस कोड के माध्यम से A1 cell की font style को Arial, size 14, bold, italic और underline किया गया है, और उसका रंग लाल (Red) किया गया है।

Applying Various Background Properties in Excel VBA in Hindi

Excel VBA में background properties का मतलब होता है कि cell का background color या उसका pattern कैसा दिखेगा। इसे हम Interior Property के द्वारा नियंत्रित करते हैं।

  • Interior.Color: इससे background color सेट किया जाता है।
  • Interior.Pattern: यह सेट करता है कि cell में कोई pattern हो या न हो।
  • Interior.PatternColor: इससे pattern का रंग तय किया जाता है।

नीचे एक उदाहरण दिया गया है:

Sub SetCellBackground()
  Range("B2").Interior.Color = RGB(200, 255, 200)
  Range("B2").Interior.Pattern = xlPatternSolid
End Sub

यह कोड B2 cell का background हल्के हरे रंग में बदल देगा।

Formatting Cells with Fonts and Backgrounds in Hindi

अब अगर आप एक साथ font और background दोनों properties को apply करना चाहते हैं, तो आप एक ही macro में दोनों चीज़ें शामिल कर सकते हैं। Excel VBA आपको यह flexibility देता है कि आप एक ही समय में multiple formatting options use कर सकें।

नीचे एक combined example दिया गया है:

Sub FormatCellCompletely()
  With Range("C3")
    .Font.Name = "Calibri"
    .Font.Size = 12
    .Font.Color = RGB(0, 0, 255)
    .Font.Bold = True
    .Interior.Color = RGB(255, 255, 0)
  End With
End Sub

इस कोड में C3 cell का font Calibri और size 12 होगा, रंग नीला (Blue) होगा, bold format में होगा, और उसका background रंग पीला (Yellow) होगा।

Other Font Related Customizations in Excel VBA in Hindi

कुछ अन्य महत्वपूर्ण font properties जो उपयोगी हो सकती हैं:

  • Font.Strikethrough: इससे text के ऊपर एक रेखा आ जाती है।
  • Font.Superscript: यह text को ऊपर उठाकर दिखाता है, जैसे x²।
  • Font.Subscript: यह text को नीचे गिराकर दिखाता है, जैसे H₂O।
Sub ExtraFontFeatures()
  Range("D4").Font.Strikethrough = True
  Range("D4").Font.Superscript = True
End Sub

ऊपर दिया गया कोड D4 cell में लिखे text को strike-through और superscript दोनों बना देगा।

Color Table for Font and Background in Excel VBA in Hindi

नीचे कुछ commonly used colors के RGB values दिए गए हैं:

Color Name RGB Code
Red RGB(255, 0, 0)
Green RGB(0, 255, 0)
Blue RGB(0, 0, 255)
Yellow RGB(255, 255, 0)
Light Gray RGB(211, 211, 211)

Best Practices for Fonts and Backgrounds in Excel VBA in Hindi

  • हमेशा With...End With का प्रयोग करें जब एक ही cell पर कई properties लागू करनी हो।
  • Readable colors चुनें जिससे visibility बनी रहे।
  • Font size को consistent रखें ताकि पूरा डेटा uniform दिखे।
  • Background color बहुत गहरा न रखें जिससे text पढ़ने में कठिनाई न हो।

Excel VBA में font और background formatting सीखने के बाद आप अपने spreadsheet को visually appealing और professional बना सकते हैं। यह डेटा को अच्छे से प्रस्तुत करने में भी मदद करता है और user को समझने में आसानी होती है।

FAQs

Font Property का उपयोग Excel VBA में किसी भी cell के अंदर लिखे गए text की लिखावट (जैसे font name, size, bold, italic, underline आदि) को control करने के लिए किया जाता है।
Font size बदलने के लिए आप Range("A1").Font.Size = 14 जैसे code का उपयोग कर सकते हैं जिससे A1 cell का font size 14 हो जाएगा।
Background color लगाने के लिए आप Range("A1").Interior.Color = RGB(255,255,0) जैसे code का उपयोग कर सकते हैं जिससे cell का background रंग yellow हो जाएगा।
Interior Property का उपयोग Excel VBA में किसी cell के अंदर background color और pattern सेट करने के लिए किया जाता है। इससे आप background का रंग और design बदल सकते हैं।
आप With Range("A1") जैसे block का उपयोग करके font और background दोनों properties एक साथ apply कर सकते हैं जिससे code छोटा और manage करना आसान हो जाता है।
हाँ, आप एक ही macro में .Font.Color और .Interior.Color दोनों को define करके font और background color एक साथ सेट कर सकते हैं।

Please Give Us Feedback