Correction of the Macro in which we can put formula

zyxw1234
Banned
Posts: 253
Joined: 22 Apr 2020, 17:24

Correction of the Macro in which we can put formula

Post by zyxw1234 »

Plz see the vba macro from the below link
https://drive.google.com/open?id=11FAIt ... 7uSJ5dzXgS

User avatar
HansV
Administrator
Posts: 78446
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Correction of the Macro in which we can put formula

Post by HansV »

You have some quoted strings such as "BUY" in the formula. This formula itself is a quoted string. That causes confusion. To solve this, double the quotes for strings inside the formula. So for example, "BUY" becomes ""BUY""
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78446
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Correction of the Macro in which we can put formula

Post by HansV »

By the way, you can include code in your posts. Enclose it in [code] and [/code] tags. For example, your macro on Google Docs is:

Code: Select all

Sub test()
  Dim Wb1 As Workbook, WS1 As Worksheet, Lr1 As Long
  Set Wb1 = Workbooks.Open("C:\Users\Desktop\TEST.xlsx")
  Set WS1 = Wb1.Worksheets.Item(1)
  Let Lr1 = WS1.Range("H" & WS1.Rows.Count).End(xlUp).Row
   WS1.Range("J2:J" & Lr1 & "").Value = "=IF(D2<H2,"BUY",IF(D2>H2,"SHORT","Delete"))"
   WS1.Range("J2:J" & Lr1 & "").Value = WS1.Range("J2:J" & Lr1 & "").Value
   
   Wb1.Save
   Wb1.Close
End Sub
Best wishes,
Hans

zyxw1234
Banned
Posts: 253
Joined: 22 Apr 2020, 17:24

Re: Correction of the Macro in which we can put formula

Post by zyxw1234 »

Thnx Alot HansV Sir for helping me in solving this problem
Problem Solved
I tried to put the code in the post but i am getting error in pasting the code in this forum(/) this is been removed automatically

User avatar
Leif
Administrator
Posts: 7209
Joined: 15 Jan 2010, 22:52
Location: Middle of England

Re: Correction of the Macro in which we can put formula

Post by Leif »

zyxw1234 wrote:
26 May 2020, 13:58
I tried to put the code in the post but i am getting error in pasting the code in this forum(/) this is been removed automatically
Where are you copying it from?
Leif

User avatar
HansV
Administrator
Posts: 78446
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Correction of the Macro in which we can put formula

Post by HansV »

If you copy code from the visual Basic Editor into a post, you shouldn't have problems.
Best wishes,
Hans

zyxw1234
Banned
Posts: 253
Joined: 22 Apr 2020, 17:24

Re: Correction of the Macro in which we can put formula

Post by zyxw1234 »

From excel, its not this website fault, I think my system fault