hello ,i am having trouble making a small vbs sript to copy data in an excel file.
Sorry ,new at this.
I want to copy data from column B or C to column D(byscript) .The condition to chose between column B or C is that column A is 0,00 or 20,00
result should look like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl69, width: 64"][/TD]
[TD="class: xl65, width: 64"]0[/TD]
[TD="class: xl65, width: 64"]20[/TD]
[TD="class: xl67, width: 64"]bymacro[/TD]
[/TR]
[TR]
[TD="class: xl70"]0,00[/TD]
[TD="class: xl66"]7001[/TD]
[TD="class: xl66"]7010[/TD]
[TD="class: xl68"]7001[/TD]
[/TR]
[TR]
[TD="class: xl70"]0,00[/TD]
[TD="class: xl66"]7002[/TD]
[TD="class: xl66"]7011[/TD]
[TD="class: xl68"]7002[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7003[/TD]
[TD="class: xl66"]7012[/TD]
[TD="class: xl68"]7012[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7004[/TD]
[TD="class: xl66"]7013[/TD]
[TD="class: xl68"]7013[/TD]
[/TR]
[TR]
[TD="class: xl70"]0,00[/TD]
[TD="class: xl66"]7005[/TD]
[TD="class: xl66"]7014[/TD]
[TD="class: xl68"]7005[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7006[/TD]
[TD="class: xl66"]7015[/TD]
[TD="class: xl68"]7015[/TD]
[/TR]
[TR]
[TD="class: xl70"]0,00[/TD]
[TD="class: xl66"]7007[/TD]
[TD="class: xl66"]7016[/TD]
[TD="class: xl68"]7007[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7008[/TD]
[TD="class: xl66"]7017[/TD]
[TD="class: xl68"]7017[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7009[/TD]
[TD="class: xl66"]7018[/TD]
[TD="class: xl68"]7018[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
I have this ,sofar: (i have no errros, but its not copying anything)
thx alot for any help !
Sorry ,new at this.
I want to copy data from column B or C to column D(byscript) .The condition to chose between column B or C is that column A is 0,00 or 20,00
result should look like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl69, width: 64"][/TD]
[TD="class: xl65, width: 64"]0[/TD]
[TD="class: xl65, width: 64"]20[/TD]
[TD="class: xl67, width: 64"]bymacro[/TD]
[/TR]
[TR]
[TD="class: xl70"]0,00[/TD]
[TD="class: xl66"]7001[/TD]
[TD="class: xl66"]7010[/TD]
[TD="class: xl68"]7001[/TD]
[/TR]
[TR]
[TD="class: xl70"]0,00[/TD]
[TD="class: xl66"]7002[/TD]
[TD="class: xl66"]7011[/TD]
[TD="class: xl68"]7002[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7003[/TD]
[TD="class: xl66"]7012[/TD]
[TD="class: xl68"]7012[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7004[/TD]
[TD="class: xl66"]7013[/TD]
[TD="class: xl68"]7013[/TD]
[/TR]
[TR]
[TD="class: xl70"]0,00[/TD]
[TD="class: xl66"]7005[/TD]
[TD="class: xl66"]7014[/TD]
[TD="class: xl68"]7005[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7006[/TD]
[TD="class: xl66"]7015[/TD]
[TD="class: xl68"]7015[/TD]
[/TR]
[TR]
[TD="class: xl70"]0,00[/TD]
[TD="class: xl66"]7007[/TD]
[TD="class: xl66"]7016[/TD]
[TD="class: xl68"]7007[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7008[/TD]
[TD="class: xl66"]7017[/TD]
[TD="class: xl68"]7017[/TD]
[/TR]
[TR]
[TD="class: xl70"]20,00[/TD]
[TD="class: xl66"]7009[/TD]
[TD="class: xl66"]7018[/TD]
[TD="class: xl68"]7018[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
I have this ,sofar: (i have no errros, but its not copying anything)
Code:
Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim myFile As String
Dim LastRow As Long
Dim rng As Range
myFile = Application.GetOpenFilename
Workbooks.Open Filename:=myFile
LastRow = ActiveWorkbook.Sheets("Blad1").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For Each rng In Range("A2:A" & LastRow)
If rng = 20 Then
rng.Offset(0, 3) = rng.Offset(0, 2)
Else
rng.Offset(0, 3) = rng.Offset(0, 1)
End If
Next rng
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub