سلول رنگی

Collapse
این تاپیک قفل است.
X
X
 
  • زمان
  • نمایش
حذف همه
new posts
  • كامران

    • 2016/06/29
    • 147
    • 41.00

    [حل شده] سلول رنگی

    سلام
    برای یکی از کارهام احتیاج دارم که کدی بنویسم شبیه زیر
    کد:
    cells(1,1) = "1234567890"
    با این فرق که میخوام نتیجه اینجوری توی سل بیاد
    1234567890
    البته اون رنگها برا نمونه است و منظورم دقیقآ همون رنگها نیست
    آیا اینکار قابل انجامه یا نه؟؟
  • mahdi2013

    • 2014/09/22
    • 38

    #2
    با سلام
    امیدوارم به دردتون بخوره
    سلول مورد نظر انتخاب کنید و ماکرو را اجرا کنید و در پنجره باز شده متن دلخواه را بنویسید
    کد:
    Sub ColorfullTextString()
    
    Dim Cel_Color01 As String
    Dim Cel_Color02 As String
    Dim Cel_Color03 As String
    Dim Cel_Color04 As String
    Dim Cel_Color05 As String
    
    'Color
        Cel_Color01 = rgbRed
        Cel_Color02 = rgbGreen
        Cel_Color03 = rgbBlue
        Cel_Color04 = rgbOlive
        Cel_Color05 = rgbOrange
        
        ActiveCell.Select
        ActiveCell.FormulaR1C1 = InputBox("Please input data")
        
        With ActiveCell.Characters(Start:=1, Length:=3).Font
            .Name = "Calibri"
            .FontStyle = "Regular"
            .Size = 11
            .Color = Cel_Color01
        End With
        With ActiveCell.Characters(Start:=4, Length:=3).Font
            .Name = "Calibri"
            .FontStyle = "Regular"
            .Size = 11
            .Color = Cel_Color02
        End With
        With ActiveCell.Characters(Start:=9, Length:=3).Font
            .Name = "Calibri"
            .FontStyle = "Bold Italic"
            .Size = 11
            .Color = Cel_Color03
        End With
         With ActiveCell.EntireColumn.AutoFit = True
         End With
    End Sub

    کامنت

    • كامران

      • 2016/06/29
      • 147
      • 41.00

      #3
      نوشته اصلی توسط mahdi2013
      با سلام
      امیدوارم به دردتون بخوره
      سلول مورد نظر انتخاب کنید و ماکرو را اجرا کنید و در پنجره باز شده متن دلخواه را بنویسید
      کد:
      Sub ColorfullTextString()
      
      Dim Cel_Color01 As String
      Dim Cel_Color02 As String
      Dim Cel_Color03 As String
      Dim Cel_Color04 As String
      Dim Cel_Color05 As String
      
      'Color
          Cel_Color01 = rgbRed
          Cel_Color02 = rgbGreen
          Cel_Color03 = rgbBlue
          Cel_Color04 = rgbOlive
          Cel_Color05 = rgbOrange
          
          ActiveCell.Select
          ActiveCell.FormulaR1C1 = InputBox("Please input data")
          
          With ActiveCell.Characters(Start:=1, Length:=3).Font
              .Name = "Calibri"
              .FontStyle = "Regular"
              .Size = 11
              .Color = Cel_Color01
          End With
          With ActiveCell.Characters(Start:=4, Length:=3).Font
              .Name = "Calibri"
              .FontStyle = "Regular"
              .Size = 11
              .Color = Cel_Color02
          End With
          With ActiveCell.Characters(Start:=9, Length:=3).Font
              .Name = "Calibri"
              .FontStyle = "Bold Italic"
              .Size = 11
              .Color = Cel_Color03
          End With
           With ActiveCell.EntireColumn.AutoFit = True
           End With
      End Sub
      ممنون ولی این برای کارهای دستیه نمیشه تو یه پروسه جاش بدی احتمالآ سوالمو درست نپرسیدم
      به کد پائین دقت کنید

      کد:
      a = "123" & chr(13) & "asd" & chr(13) & "kjh"
      msgbox a
      که نتیجه ش میشه
      123
      asd
      kjh

      سوال من اینه که کاراکتری چیزی مثل chr(13) که اینتر میسازه هست یذاریم بین متنها که رنگ بسازه ؟

      کامنت

      • mahdi2013

        • 2014/09/22
        • 38

        #4
        سؤالتون گویا نیست لطفا نمونه فایل بگذارید

        کامنت

        • كامران

          • 2016/06/29
          • 147
          • 41.00

          #5
          نوشته اصلی توسط mahdi2013
          سؤالتون گویا نیست لطفا نمونه فایل بگذارید
          خلاصه ش میشه این

          کد:
           a = کدی یا دستوری که دنبالشم
          b = "123" & a & "456" & a & "789" & a & "0"
           cells (1,1) = b
          و در سلول a1 بجای 1234567890 عبارت
          123456789​0
          درج بشه

          کامنت

          • Amir Ghasemiyan

            • 2013/09/20
            • 4598
            • 100.00

            #6
            نوشته اصلی توسط كامران
            خلاصه ش میشه این

            کد:
             a = کدی یا دستوری که دنبالشم
            b = "123" & a & "456" & a & "789" & a & "0"
             cells (1,1) = b
            و در سلول a1 بجای 1234567890 عبارت
            123456789​0
            درج بشه


            سلام دوست عزيز
            دو نكته
            1- اول اينكه اين تغيير رنگ فقط در صورتي اعمال ميشه كه عبارت وارد شده تكست باشه (يا فرمت سلول تكست باشه)
            2- اين تغيير رنگ بايد بعد از درج مقدار در سلول اعمال بشه

            كد خلاصه اي كه اينكار رو ميتونه براتون انجام بده به اين صورته:

            کد:
            Sub ColorfullTextString()
            
            
            Dim Cel_Color01 As String
            Dim Cel_Color02 As String
            Dim Cel_Color03 As String
            Dim Cel_Color04 As String
            Dim Cel_Color05 As String
            
            
            'Color
            Cel_Color01 = rgbRed
            Cel_Color02 = rgbGreen
            Cel_Color03 = rgbBlue
            Cel_Color04 = rgbOlive
            Cel_Color05 = rgbOrange
            
            
            With Range("A5")
                .NumberFormat = "@"
                .Value = "1234567890"
                .Characters(Start:=1, Length:=3).Font.Color = Cel_Color01
                .Characters(Start:=4, Length:=3).Font.Color = Cel_Color02
                .Characters(Start:=9, Length:=3).Font.Color = Cel_Color03
            End With
            
            
            End Sub

            کامنت

            چند لحظه..