VBA to Script

YupImHere

New Member
Joined
Feb 24, 2023
Messages
5
Office Version
  1. 2013
Platform
  1. Windows
Yea, I have no idea where to start. I have been all over google trying to figure out the structure. I have a VBA that i need to put into a script inorder to use it in AppSheet. Can you point me in the right direction?

Sub ResetWeekly()

End Sub
Sub ClearOldDates()
'Declare variables
Dim rng As Range
Dim fng As Range
Dim gng As Range
Dim sta As Range
Dim cell As Range
Dim today As Date

'Set the range to be looped through
Set rng = Range("E2:E49")

'Get today's date
today = Date

'Loop through each cell in the range
For Each cell In rng

'Check if the date in the cell is more than 7 days old
If cell.Value < DateAdd("d", -7, today) Then

'Clear the contents of the cell
cell.ClearContents

End If

Next cell

Set fng = Range("F2:F49")
today = Date
For Each cell In fng
If cell.Value < DateAdd("d", -7, today) Then
cell.ClearContents
End If
Next cell

Set gng = Range("g2:g49")
today = Date
For Each cell In gng
If cell.Value < DateAdd("d", -7, today) Then
cell.ClearContents
End If
Next cell

Set sta = Range("h2:h49")
For Each cell In sta
If cell.Value = "" Then Intersect(sta.EntireRow, Columns("H:H")).ClearContents

Next cell

End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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