calculation by vba

agog12

Board Regular
Joined
Jan 23, 2018
Messages
104
vba is placed in a seperate file c.xlsm
both files are located in a same place
there is a file name sample1.xlsx
open sample1.xlsx
in column N we have to use the formula =H2/M2 and paste the result in values in column N of sample1.xlsx
and in coulmn Q we have to use the formula =N2*P2 and paste the result in values in column Q of sample1.xlsx
and save and close the sample1.xlsx


note we have to use the formula till the end of the data (till the column H has data )
example if column H has data till H17 then we have to use the formula till
N17 & Q17

so plz have a look sir and help me in solving this problem by vba macro sir
 
As i mentioned it should paste the data till column H has data and once it reaches the end of data it should stop
example
column H has data till H15 then the vba code should work with only from N2 to N17 & Q2 to Q17
it has a headers thats y started from N2 and Q2
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
what this macro is doing it is pasting the data to N17 & Q17 perfectly but after N17 &Q17
it is showing Div something like this error
 
Upvote 0
Still need to know what the macro in post number 10 produces.
 
Upvote 0
I give up, I am obviously not going to get an answer to my question.
 
Upvote 0
yes i ran ur code i got 65537


Sub test1()
Dim wb As Workbook, sh As Worksheet, lr As Long
Set wb = Workbooks.Open(ThisWorkbook.Path & "\sample1.xlsx")
Set sh = wb.Sheets(1)
lr = sh.Range("H" & Rows.Count).End(3).Row
MsgBox lr
End Sub
 
Upvote 0
That is what is the issue then. A few questions...
Do you have formulas returning "" in the whole of column H in your sample1 workbook, Sheet(1)?
If no then put the formulas below in empty cells in the sheet and tell me what they return
=ISBLANK(H65537)
=CODE(H65537)

Edit: Also what version of Excel are you using?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,858
Members
449,194
Latest member
HellScout

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