How to change access vba (1 Viewer)

btamsgn

Member
Local time
Today, 16:37
Joined
Nov 8, 2010
Messages
50
Hi everyone,
How to change part in bold into access vba ?
Sub Balaco()
Dim sArr(), res(), sRow&, i&
Const e# = 10 ^ (-12) 'Sai so cho phep
Const n& = 50 ' results rows found

i = Range("B999999").End(xlUp).Row
res = Range("B3:C" & i).Value 'data table "Tnpl"
sArr = Range("B3:C" & i).Value 'data table "Tnpl"
Range("B3:C" & i).Value = res
Tong = Range("F3").Value 'Tong field from table "Tong"
sRow = UBound(sArr)

Range("G3").Resize(n, 3) = res 'Table "output"

End Sub
 

Attachments

  • Hmany (2).zip
    21.9 KB · Views: 140
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:37
Joined
May 7, 2009
Messages
19,169
you post the original excel file so we can see what you mean.
 

btamsgn

Member
Local time
Today, 16:37
Joined
Nov 8, 2010
Messages
50
you post the original excel file so we can see what you mean.
Dear arnelgp,
Pls find the original excel file in the attachment for your ref.
Pls advise and change vba above into access vba, thanks.
 

Attachments

  • tim ma hang theo dk.zip
    17.4 KB · Views: 131

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:37
Joined
May 7, 2009
Messages
19,169
the excel file only calculate for 3 columns.
 

Attachments

  • Hmany_3.accdb
    608 KB · Views: 129

btamsgn

Member
Local time
Today, 16:37
Joined
Nov 8, 2010
Messages
50
the excel file only calculate for 3 columns.
1. Yes, only 3 columns but I can control results in it
for example: in vba const=50 rows
2. I found the code in it that's good, however, I can't change the code into access vba?
You can change bold part into vba access with thanks and I can learn code from you and have a knowledge about excel code and access code.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:37
Joined
Feb 28, 2001
Messages
26,996
Apologies - I misunderstood your question. I read it wrong and therefore got confused. That's my fault for reading too fast and missing a key word. I'm going to remove my answer since it was based on a misunderstanding of the question.

You asked (in post #6):

however, I can't change the code into access vba?

I wish to clarify something. When I went off target earlier, one thing I said earlier was still correct - Access and Excel both use the same VBA processor. In the strict sense, there IS no "Access VBA" vs. "Excel VBA." It is the objects on which they will work that would be different. VBA will be the language they use in either case to work on the objects they have. Therefore, what you have shown us could be executed equally well from Access or from Excel, presuming that in either case there was an Excel object to define the ranges involved.

Structurally, Access is not at all like Excel. To make the change you wanted, you must build a table structure in Access to correspond to the Excel data layout you are trying to convert. Then we can talk about how to approach the problem. I see that Arnel provided something for you to examine. But to learn either Excel or Access coding techniques, you must first understand the object models that they use because it is those object models that define the structure.
 

btamsgn

Member
Local time
Today, 16:37
Joined
Nov 8, 2010
Messages
50
the excel file only calculate for 3 columns.
Dear arnelgp,
I click on new code Sub XYZ(ByVal Tong#), however, It doesn't work
1648794552309.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:37
Joined
May 7, 2009
Messages
19,169
its not coming because it is not actually 16.5.
from your excel you copy and paste your formula (copy->paste->Value) and
the result is not 16.5 but 16.5000000000074.
cp1.png



so if you paste that value 16.5000000000074 to your ms access it will give you
the result:

cp2.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:37
Joined
May 7, 2009
Messages
19,169
actually the result is same as in excel, only the order/arrangement is different.
 

Users who are viewing this thread

Top Bottom