vba dictionary -text to number issue

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
976
Office Version
  1. 2010
Platform
  1. Windows
Hi Team,

I am adding data to dictionary and printing dictionary values to Range.
But text data getting pasted as number.how to retain it original value. Thanks


VBA Code:
Sub Copy_Columns_with_Formatting()
   
   Dim Cl As Range
   Dim rng_total As Range
   Dim rng_Team As Range
   
   Set rng_Team = Range("A1:J1").Find("Team", lookat:=xlWhole)
   Set rng_total = Range("A1:J1").Find("Test Century", lookat:=xlWhole)
   
    Dim dict As New Scripting.Dictionary
       
       With dict
       
         For Each Cl In Range("b2", Range("b" & Rows.Count).End(xlUp))
              .Item(Cl.Value) = Array(Cells(Cl.Row, rng_Team.Column), Cells(Cl.Row, rng_total.Column))
         Next Cl
        
    Range("G2:H" & dict.Count + 1).Value = Application.Index(dict.items, 0, 0)
   
   
   End With
   
End Sub

Book3
ABCDEFGHI
1Sr NoPlayer NamePeriodTeamTest CenturyPlayer NameTest Century
21Sachin Tendulkar1989–2013 India51 India51
32Ricky Ponting1995–2012 Australia41 Australia41<==Text value converted into Number
43Virat Kohli2008–2020 India27 India27While pasting from dictionary
54Kumar Sangakkara2000–2015 Sri Lanka38 Sri Lanka38
65Jacques Kallis1995–2014 South Africa45 South Africa45
76Hashim Amla2004–2019 South Africa28 South Africa28
87Mahela Jayawardene1997–2015 Sri Lanka34 Sri Lanka34
98Brian Lara1990–2007 West Indies34 West Indies34
109Rahul Dravid1996–2012 India36 India36
1110AB de Villiers2004–2018 South Africa22 South Africa22
1211David Warner2009–2020 Australia24 Australia24
1312Sanath Jayasuriya1989–2011 Sri Lanka14 Sri Lanka14
1413Chris Gayle1989–2011 West Indies25 West Indies25
1514Shivnarine Chanderpaul1989–2011 West Indies30 West Indies30
1615Ross Taylor1989–2011New Zealand7New Zealand7
1716Matthew Hayden1993–2009 Australia30 Australia30
1817Gary Kirsten1993–2004 South Africa21 South Africa21
1918Kane Williamson1993–2004 New Zealand13 New Zealand13
2019Adam Gilchrist1996–2008 Australia17 Australia17
2120Joe Root2004–2014 England16 England16
2221Kevin Pietersen2004–2014 England23 England23
2322Javed Miandad1975–1996 Pakistan23 Pakistan23
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B23Cell ValueduplicatestextNO
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi Team,
Actual Screen shot of Colum E. expecting same as in output column.

Thanks mg
 

Attachments

  • Text value.PNG
    Text value.PNG
    3.9 KB · Views: 4
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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