Ok I have a worksheet with two sheets: Download and Historical
The Download sheet looks like this:
SSE [% Chg] Aarhuskarlshamn ABB ... kuk
Friday, April 20, 2013 -0.48 -0.29 ... 5
The Historical sheet looks like this:
SSE [% Chg] Aarhuskarlshamn ABB ...
Friday, April 19, 2013 -0.48 -0.29 ...
Later of course the % Chg will be different but right now they are the same (it does not matter).
Note that the Download sheet has one more stock than the Historical sheet.
Now I have made two procedures called Store() and Check()
(See attached files or see below)
You first run Store() and then Check() this will result in that the Historical sheet looks like this:
SSE [% Chg] Aarhuskarlshamn ABB ...
Friday, April 19, 2013 -0.48 -0.29 ...
Friday, April 20, 2013 -0.48 -0.29 ...
SSE [% Chg] Aarhuskarlshamn ABB ...
Friday, April 20, 2013 -0.48 -0.29 ...
252 1 2
Everything is working except for what happens in the end of Historical sheet. It looks like this:
Yara International ?
3.09
3.09 5
Yara International kuk
3.09 5
297 144
This is very strange because where there is a ? mark the name kuk should appear. This is puzzling.
The two procedures Store() and Check() looks like this:
I have tried to find an error but I cant find one. Can anyone spot the problem?
https://skydrive.live.com/redir?resid=1119584707219896!644&authkey=!ACXcJOqW17OU5d4
https://skydrive.live.com/redir?resid=1119584707219896!643&authkey=!APe6K_ETT4MwhNo
https://skydrive.live.com/redir?resid=1119584707219896!645&authkey=!AL3e1antXDlOEtI
The Download sheet looks like this:
SSE [% Chg] Aarhuskarlshamn ABB ... kuk
Friday, April 20, 2013 -0.48 -0.29 ... 5
The Historical sheet looks like this:
SSE [% Chg] Aarhuskarlshamn ABB ...
Friday, April 19, 2013 -0.48 -0.29 ...
Later of course the % Chg will be different but right now they are the same (it does not matter).
Note that the Download sheet has one more stock than the Historical sheet.
Now I have made two procedures called Store() and Check()
(See attached files or see below)
You first run Store() and then Check() this will result in that the Historical sheet looks like this:
SSE [% Chg] Aarhuskarlshamn ABB ...
Friday, April 19, 2013 -0.48 -0.29 ...
Friday, April 20, 2013 -0.48 -0.29 ...
SSE [% Chg] Aarhuskarlshamn ABB ...
Friday, April 20, 2013 -0.48 -0.29 ...
252 1 2
Everything is working except for what happens in the end of Historical sheet. It looks like this:
Yara International ?
3.09
3.09 5
Yara International kuk
3.09 5
297 144
This is very strange because where there is a ? mark the name kuk should appear. This is puzzling.
The two procedures Store() and Check() looks like this:
Code:
Public Sub Store()
Dim LastrowDownload As Integer
Dim LastcolumnDownload As Integer
Dim LastrowHistorical As Integer
LastrowDownload = Worksheets("Download").Range("A" & Rows.Count).End(xlUp).Row
LastcolumnDownload = Worksheets("Download").Cells(1, Columns.Count).End(xlToLeft).Column
ColLetterDownload = Application.WorksheetFunction.Substitute(Worksheets("Download").Cells(1, LastcolumnDownload).Address(0, 0), "1", "")
LastrowHistorical = Worksheets("Historical").Range("A" & Rows.Count).End(xlUp).Row
'Sheets("Sheet1").Cells(11, 1).Value = ColLetterDownload
If LastrowHistorical = 1 Then
Sheets("Historical").Range("A" & LastrowHistorical & ":" & ColLetterDownload & 2).Value = Sheets("Download").Range("A1:" & ColLetterDownload & 2).Value
LastrowHistorical = Worksheets("Historical").Range("A" & Rows.Count).End(xlUp).Row
End If
If LastrowHistorical <> 1 And Sheets("Download").Cells(2, 1).Value <> Sheets("Historical").Cells(LastrowHistorical, 1).Value Then
Sheets("Historical").Range("A" & LastrowHistorical + 3 & ":" & ColLetterDownload & LastrowHistorical + 3 + 1).Value = Sheets("Download").Range("A1:" & ColLetterDownload & 2).Value
End If:
End Sub
Public Sub Check()
Dim i As Integer
Dim j As Integer
LastcolumnDownload = Worksheets("Download").Cells(1, Columns.Count).End(xlToLeft).Column
LastcolumnHistorical = Worksheets("Historical").Cells(1, Columns.Count).End(xlToLeft).Column
ColLetterHistorical = Application.WorksheetFunction.Substitute(Worksheets("Historical").Cells(1, LastcolumnHistorical).Address(0, 0), "1", "")
ColLetterHistoricalNew = Application.WorksheetFunction.Substitute(Worksheets("Historical").Cells(1, LastcolumnHistorical + 1).Address(0, 0), "1", "")
LastrowHistorical = Worksheets("Historical").Range("A" & Rows.Count).End(xlUp).Row
'Worksheets("Historical").Cells(20, 1).Value = ColLetterHistoricalNew & 2 & ":" & ColLetterHistoricalNew & LastrowHistorical - 4
'Worksheets("Historical").Cells(21, 1).Value = LastcolumnHistorical
For j = 1 To LastcolumnDownload Step 1
If IsError(Application.Match(Worksheets("Historical").Cells(LastrowHistorical - 1, j).Value, Sheets("Historical").Range("B1:" & ColLetterHistorical & 1).Value)) = True Then
Worksheets("Historical").Cells(10, j) = 0
Worksheets("Historical").Cells(1, LastcolumnHistorical + 1).Value = Sheets("Historical").Cells(LastrowHistorical - 1, j).Value
Worksheets("Historical").Cells(LastrowHistorical - 3, LastcolumnHistorical + 1).Value = Sheets("Historical").Cells(LastrowHistorical, j).Value
'For i = 2 To LastrowHistorical - 4 Step 1
'Worksheets("Historical").Cells(i, LastcolumnHistorical + 1).Value = 0
'Next i
LastcolumnHistorical = Worksheets("Historical").Cells(1, Columns.Count).End(xlToLeft).Column
ColLetterHistorical = Application.WorksheetFunction.Substitute(Worksheets("Historical").Cells(1, LastcolumnHistorical).Address(0, 0), "1", "")
ColLetterHistoricalNew = Application.WorksheetFunction.Substitute(Worksheets("Historical").Cells(1, LastcolumnHistorical + 1).Address(0, 0), "1", "")
Else
Worksheets("Historical").Cells(LastrowHistorical - 3, j).Value = Sheets("Historical").Cells(LastrowHistorical, j).Value
Worksheets("Historical").Cells(10, j) = Application.Match(Worksheets("Historical").Cells(LastrowHistorical - 1, j).Value, Sheets("Historical").Range("B1:" & ColLetterHistorical & 1).Value)
End If
Next j
End Sub
I have tried to find an error but I cant find one. Can anyone spot the problem?
https://skydrive.live.com/redir?resid=1119584707219896!644&authkey=!ACXcJOqW17OU5d4
https://skydrive.live.com/redir?resid=1119584707219896!643&authkey=!APe6K_ETT4MwhNo
https://skydrive.live.com/redir?resid=1119584707219896!645&authkey=!AL3e1antXDlOEtI
Last edited by a moderator: