Detailed explanation of how to rewrite formulas in Excel into VBA

WBOY
Release: 2024-01-05 16:25:30
forward
1042 people have browsed it

How to rewrite formulas in Excel into VBA

Set the table name to sheet1, where column A is the country name and column B is the corresponding number (modify it according to the actual situation).

To help players who have not yet passed the level, we can use the following macros to solve the puzzle. Just create and execute this macro to achieve your goal.

Sub aaaa()

Dim Target As Range

Do

i = i 1

In order to help those players who have not passed the level yet, let us learn about the specific puzzle solving methods. In the code, we use "Sheet1.Range("A" & i).Text" to get the text content in cell A. This method can help us obtain the information we need and then perform corresponding operations. Hope this tip helps you all!

Select Case aaa

Case "China"

Sheet1.Range("B" & i) = 2

Case "USA"

Sheet1.Range("B" & i) = 1

Case "Japan"

Sheet1.Range("B" & i) = 0

End Select

Loop While aaa """

End Sub

Excel formula to VBA code

There is something wrong with the logical relationship of your formula

Please see if this is what it means

Sub test()

Dim i&, n, n1

For i = 1 To 5

If Cells(i, "D") * Pi / 180 >= 0 Then

If Cos(Cells(i, "B") * Pi / 180 - Cells(i, "I") * Pi / 180) < 0 Then

n = True

Else

n = False

End If

If Cos(Cells(i, "B") * Pi / 180 - Cells(i, "I") * Pi / 180) > 0 Then

n1 = True

Else

n1 = False

End If

If n1 = True And n = True Then k = "-1" Else k = "1"

Else

k = "1"

End If

Cells(i, "A") = k

Next i

End Sub

The above is the detailed content of Detailed explanation of how to rewrite formulas in Excel into VBA. For more information, please follow other related articles on the PHP Chinese website!

source:docexcel.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template