Use of sendkeys in excel with ALT Key

partha.raha

New Member
Joined
Sep 30, 2008
Messages
19
Hi
I am trying to use a macro to automate the use of alt key.

my code looks like this-->
Private Sub CommandButton1_Click()
For i = 0 To 10
Range("A" & i).Value = ActiveSheet.SendKeys("%" & i)
Next i
End Sub

This code is to enter the value of ALT+1...ALT+10 to column A
Plz help..
 
Hi,
Earlier I got u wrong..
Now that I have entered ALT+1,2....10 in A1:A10
and ran the script, in B1:B10 I got
<table x:str="" style="border-collapse: collapse; width: 48pt;" width="64" border="0" cellpadding="0" cellspacing="0"><col style="width: 48pt;" width="64"> <tbody><tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt; width: 48pt;" width="64" align="left" height="17">58(38)</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" align="left" height="17">59(38)</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" align="left" height="17">101(38)</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" align="left" height="17">102(38)</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" align="left" height="17">99(38)</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" align="left" height="17">96(38)</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" align="left" height="17">34(32)</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" align="left" height="17">216(37)</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" align="left" height="17">203(37)</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" align="left" height="17">217(37)</td> </tr> </tbody></table>
Hope now you will be able to solve my problem :)
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
What font are you using?

PS You really should avoid using SendKeys, as you've seen already it's not very reliable.:)
 
Upvote 0
Theres almost certainly a slicker way of doing this, but the following will work:

Code:
Sub Insert_Values()
Dim arrChar As Variant, arrSet As Variant, i As Long, b(0 To 1) As Byte, s As String
arrChar = VBA.Array(58, 59, 101, 102, 99, 96, 34, 216, 203, 217)
arrSet = VBA.Array(38, 38, 38, 38, 38, 38, 32, 37, 37, 37)

For i = 0 To UBound(arrChar)
    b(0) = arrChar(i): b(1) = arrSet(i)
    s = b
    Cells(i + 1, 1).Value = s
Next i
End Sub
 
Upvote 0
As you are saying that using sendkeys with ALT is not a good option.
Then I need a favour from your side.
I have designed a macro which automates some task with an external application. Now this application does it for a multiple number of records.
I have a status field as the first column in the application. I want the value to be tick or cross whenever the records are updated successfully or when they fail to do the same.
Please let me know, how can I create this tick or cross in excel.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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