hello ,i am having trouble making a small vbs sript to copy data in an exfel 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 or 20.
Results should look like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 256"]
<colgroup><col width="64" style="width:48pt"> <col width="64" span="2" style="width:48pt"> <col width="64" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl67, width: 64"] [/TD]
[TD="class: xl65, width: 64"]0[/TD]
[TD="class: xl65, width: 64"]20[/TD]
[TD="class: xl69, width: 64"]byscript[/TD]
[/TR]
[TR]
[TD="class: xl68"]0,00[/TD]
[TD="class: xl66"]7001[/TD]
[TD="class: xl66"]7010[/TD]
[TD="class: xl69"]7001[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7002[/TD]
[TD="class: xl66"]7011[/TD]
[TD="class: xl69"]7011[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7003[/TD]
[TD="class: xl66"]7012[/TD]
[TD="class: xl69"]7012[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7004[/TD]
[TD="class: xl66"]7013[/TD]
[TD="class: xl69"]7013[/TD]
[/TR]
[TR]
[TD="class: xl68"]0,00[/TD]
[TD="class: xl66"]7005[/TD]
[TD="class: xl66"]7014[/TD]
[TD="class: xl69"]7005[/TD]
[/TR]
[TR]
[TD="class: xl68"]0,00[/TD]
[TD="class: xl66"]7006[/TD]
[TD="class: xl66"]7015[/TD]
[TD="class: xl69"]7006[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7007[/TD]
[TD="class: xl66"]7016[/TD]
[TD="class: xl69"]7016[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7008[/TD]
[TD="class: xl66"]7017[/TD]
[TD="class: xl69"]7017[/TD]
[/TR]
[TR]
[TD="class: xl68"]0,00[/TD]
[TD="class: xl66"]7009[/TD]
[TD="class: xl66"]7018[/TD]
[TD="class: xl69"]7009[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
I have this ,sofar: (i have no errors but its not copying anything)
thanks 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 or 20.
Results should look like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 256"]
<colgroup><col width="64" style="width:48pt"> <col width="64" span="2" style="width:48pt"> <col width="64" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl67, width: 64"] [/TD]
[TD="class: xl65, width: 64"]0[/TD]
[TD="class: xl65, width: 64"]20[/TD]
[TD="class: xl69, width: 64"]byscript[/TD]
[/TR]
[TR]
[TD="class: xl68"]0,00[/TD]
[TD="class: xl66"]7001[/TD]
[TD="class: xl66"]7010[/TD]
[TD="class: xl69"]7001[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7002[/TD]
[TD="class: xl66"]7011[/TD]
[TD="class: xl69"]7011[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7003[/TD]
[TD="class: xl66"]7012[/TD]
[TD="class: xl69"]7012[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7004[/TD]
[TD="class: xl66"]7013[/TD]
[TD="class: xl69"]7013[/TD]
[/TR]
[TR]
[TD="class: xl68"]0,00[/TD]
[TD="class: xl66"]7005[/TD]
[TD="class: xl66"]7014[/TD]
[TD="class: xl69"]7005[/TD]
[/TR]
[TR]
[TD="class: xl68"]0,00[/TD]
[TD="class: xl66"]7006[/TD]
[TD="class: xl66"]7015[/TD]
[TD="class: xl69"]7006[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7007[/TD]
[TD="class: xl66"]7016[/TD]
[TD="class: xl69"]7016[/TD]
[/TR]
[TR]
[TD="class: xl68"]20,00[/TD]
[TD="class: xl66"]7008[/TD]
[TD="class: xl66"]7017[/TD]
[TD="class: xl69"]7017[/TD]
[/TR]
[TR]
[TD="class: xl68"]0,00[/TD]
[TD="class: xl66"]7009[/TD]
[TD="class: xl66"]7018[/TD]
[TD="class: xl69"]7009[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
I have this ,sofar: (i have no errors but its not copying anything)
Code:
Sub CommandButton1_Click()
Dim myFile As String
Dim sht As Worksheet
Dim LastRow As Long
Dim rng As Range
myFile = Application.GetOpenFilename
Workbooks.Open Filename:=myFile
Set sht = ActiveSheet
LastRow = sht.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
For Each rng In Range("A2:A" & LastRow)
If rng = "20,00" Then
rng.Offset(0, 3) = rng.Offset(0, 2)
Else
rng.Offset(0, 3) = rng.Offset(0, 1)
End If
Next rng
ActiveWorkbook.Save
End Sub
thanks alot for any help!!