• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

help on one macro vBA code

Status
Not open for further replies.

ushaanu

Member
HI all,

Greetings!!

I have one macro file . I wants add some changes on same file,
Like . if P Name contain C400,C9000 then MC and BC calculation change ,if C400,C9000
Than Calculations should be MC has to be subtract from DA3 and BC has to be subtract from NC3.

Thanks
Anu
 

Attachments

  • EXP File.xlsm
    966.5 KB · Views: 3
HI all,

Greetings!!

I have one macro file . I wants add some changes on same file,
Like . if P Name contain C400,C9000 then MC and BC calculation change ,if C400,C9000
Than Calculations should be MC has to be subtract from DA3 and BC has to be subtract from NC3.

Thanks
Anu
 

Attachments

  • EXP File.xlsm
    967.3 KB · Views: 1
I am not understanding this
Than Calculations should be MC has to be subtract from DA3 and BC has to be subtract from NC3.

Please clarify. What is subtracted from what number in each case. You have only given us 1/2 the equation. What is the subtrahend and what is the minuend and where should the difference be placed.
 
HI Alan ,

thanks for your reply .

At present in am using below VBA .
Code:
Sub MyMacro()
Dim intCount As Integer
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lngTRow, lngRow As Long

Set ws1 = Sheets("Raw Data")
Set ws2 = Sheets("SD")

'TargetDataRow
lngTRow = 8

ws1.Range("A1:B5").Copy
ws2.Range("A1").PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
ws2.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
 
ws2.Range("A7:E7") = Array("Customer Name", "RDS ID", "Device ID", "Counter", "Date")
 
For lngRow = 8 To ws1.Cells(Rows.Count, "A").End(xlUp).Row
If Not ws1.Range("G" & lngRow).Value = "N/A" Then
  ws2.Range("A" & lngTRow).Value = ws1.Range("A" & lngRow).Value
  ws2.Range("B" & lngTRow).Value = ws1.Range("C" & lngRow).Value
  ws2.Range("E" & lngTRow).Value = ws1.Range("G" & lngRow).Value
  ws2.Range("E" & lngTRow).NumberFormat = "dd-mm-yy"
  For intCount = 1 To 8
  ws2.Range("A" & lngTRow + intCount).Value = ws2.Range("A" & lngTRow).Value
  ws2.Range("B" & lngTRow + intCount).Value = ws2.Range("B" & lngTRow).Value
  ws2.Range("E" & lngTRow + intCount).Value = ws2.Range("E" & lngTRow).Value
  ws2.Range("E" & lngTRow + intCount).NumberFormat = "dd-mm-yy"
  Next intCount
  ws2.Range("D" & lngTRow).Resize(7) = Application.Transpose(ws1.Range("H" & _
  lngRow).Resize(, 7).Value)
  For intCount = 0 To 4
  If ws2.Range("D" & lngTRow + intCount).Text = "N/A" Then
  ws2.Range("D" & lngTRow + intCount).Value = 0
  End If
  Next intCount
  ws2.Range("D" & lngTRow + 7).FormulaR1C1 = "=SUM(R[-6]C:R[-5]C)"
  ws2.Range("D" & lngTRow + 8).FormulaR1C1 = "=SUM(R[-4]C:R[-5]C)"
  ws2.Range("C" & lngTRow) = ws1.Range("D" & lngRow)
  ws2.Range("C" & lngTRow + 1) = ws1.Range("D" & lngRow) & "-DA3"
  ws2.Range("C" & lngTRow + 2) = ws1.Range("D" & lngRow) & "-DA4"
  ws2.Range("C" & lngTRow + 3) = ws1.Range("D" & lngRow) & "-NC3"
  ws2.Range("C" & lngTRow + 4) = ws1.Range("D" & lngRow) & "-NC4"
  ws2.Range("C" & lngTRow + 5) = ws1.Range("D" & lngRow) & "-MC"
  ws2.Range("C" & lngTRow + 6) = ws1.Range("D" & lngRow) & "-BC"
  ws2.Range("C" & lngTRow + 7) = ws1.Range("D" & lngRow) & "-B"
  ws2.Range("C" & lngTRow + 8) = ws1.Range("D" & lngRow) & "-C"
lngTRow = lngTRow + 9
End If
Next
End Sub
 
Now I need some changes like if Model (P name ) is C400 Or c9000 in my raw worksheet than condition apply than calculation .

upload_2018-5-18_14-35-20.png


▬▬▬▬▬▬▬▬▬ Mod edit : thread closed as duplicate !

Other forum issues :

• As it's the VBA section, a title like "help on VBA code" does not reflect
the need, the subject …

• That's again a wild cross posting : see forum rules !

 
Status
Not open for further replies.
Back
Top