Katakana to hiragana VBA

llorcs

New Member
Joined
Jun 7, 2016
Messages
9
Hi all!

I have an excel file where I have to change Katakana characters to Hiragana. I've been using StrConv + vbHiragana for some time, however, it is really slow since I am using it in a range for a 1000 rows (two times). After searching around, I've found the following code, which seems like a different approach and looks really fast. My only problem is, that it only works if I select the specified row and column (e.g. from A1:A10) and then if I run it, it does the job perfectly. I need to tweak this so it automatically does it in a range and displays the results on a different sheet. (From a1:A1000 + D1:D1000)
Like this:

Sheet1:
ABCD
山田ヤマダ太郎タロウ

<tbody>
</tbody>

Sheet2:
ABCD
山田やまだ太郎たろう

<tbody>
</tbody>



Here is the code I've found:

Code:
Sub Comm()
Dim i, gyos, retus, rwsu As Integer
Dim KATA, HIRA As String


gyos = ActiveCell.Row
retus = ActiveCell.Column
rwsu = Selection.Rows.Count - 1


For n = gyos To gyos + rwsu
   KATA = Cells(n, retus)
   HIRA = StrConv(KATA, 32)
   Cells(n, retus) = HIRA
Next n


End Sub

Thank you for the help!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi,

I am not sure how I create cells with Katakana in them so I can't test this:
Code:
Sub Convert()
    Dim arr  As Variant
    Dim i    As Long
    Dim j    As Long
    
    arr = Worksheets("Sheet1").Range("A1:D1000")
    For i = 1 To UBound(arr, 1)
        For j = 1 To UBound(arr, 2)
            arr(i, j) = StrConv(arr(i, j), 32)
        Next
    Next
    Worksheets("Sheet2").Range("A1:D1000") = arr
End Sub
It reads a fixed range from Sheet1, performs the conversion then writes it back to Sheet2.

You can change the worksheet names by overtyping.

Regards,
 
Upvote 0

Forum statistics

Threads
1,215,637
Messages
6,125,965
Members
449,276
Latest member
surendra75

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