Let me start off by saying I am very new to working with excel and VBA, but do have some experience with c++.
The situation:
I'm trying to update one sheet with data found in another workbook. The source file is organized in such a way that each new work ticket is given a column. As more tickets come in, more columns are created, and various information about that ticket is listed vertically.
Basically what I'm trying to do is keep a second file updated with the same ticket numbers as the first, but with a different formatting:
Basic example of the two sheets
Here's what I have so far, although very rough for a basic idea of what I'd like the code to do:
Sub Update_Click() //Button to update destination file
Workbooks.open("C:\Documents\mysourcefile.xlsm")
dim i,j as integer
i=4 //starting column of source file where first ticket is stored
j=2 //starting column of destination file where first ticket is stored
while worksheets("mysourcesheet").Value(i,2)<>0 //all work has customer, but
//may not have a ticket
//number
if Worksheets("mysourcesheet").value(i,1) = 0 Then
i=i+1 //some columns in the source are blank due to canceled orders
//this is to go to the next column
else
if Worksheets("mysourcesheet").value(i,1)=Worksheets("mydestsheet").value(j,1)
then
i=i+1
j-j+2 //go onto the next if already updated
//J+2 to account for formatting of the cells
Else
Worksheets("mysourcesheet").value(i,1)=Worksheets("mydestsheet").value(j,1)
Worksheets("mysourcesheet").value(i,2)=Worksheets("mydestsheet").value(j,2)
Worksheets("mysourcesheet").value(i,3)=Worksheets("mydestsheet").value(j,4)
Worksheets("mysourcesheet").value(i,4)=Worksheets("mydestsheet").value(j,5)
//copy the data
i=i+1
j=j+2
end if
end if
end sub
I realize this is probably riddled with mistakes/fundamental errors, but if anybody can lend a hand that would be great!
This will copy new tickets if the customer is not empty, from 1 column in source into 2 columns