Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have declared a variable as Integer, and I am trying to put a value into it, but it will not work. Is the sentence below wrong?? When I use F8 the value of the cell is 0.3..but it will not be transferred into PVK....what is wrong? PVK = ShtMatrise.Range("BJ" & ProduktRad2).Value Does anyone have a clue on this one? Help is highly appreciated... Gunnar ------ here is the total code Sub FindPVC() Dim Produkt1 As Long Dim Produkt2 As Long Dim PasteRow As Integer Dim ProduktRad1 As Long Dim ProduktRad2 As Long Dim PVK As Integer Dim ShtFlasker As Worksheet Set ShtFlasker = Sheets("Flasker") Dim ShtMatrise As Worksheet Set ShtMatrise = Sheets("Matrise") ' Turn off screen updating to speed up macro. Application.ScreenUpdating = False ShtFlasker.Activate ProduktRad1 = 6 ProduktRad2 = 13 PasteRow = 6 Produkt1 = Range("F" & ProduktRad1).Value 'legger inn mat.# i flasker For Each c In Range("ProduktListe") ShtMatrise.Activate Produkt2 = Range("C" & ProduktRad2).Value 'legger inn mat# i matrise arket Do While Produkt1 = Produkt2 ' viss match 'ShtMatrise.Activate PVK = ShtMatrise.Range("BJ" & ProduktRad2).Value ' hente PVk verdi Selection.Copy ShtFlasker.Range("T" & PasteRow) = PVK ' overfør verdien PasteRow = PasteRow + 1 ' øk med en ProduktRad1 = ProduktRad1 + 1 Loop ProduktRad2 = ProduktRad2 + 1 Next c 'ProduktRad1 = ProduktRad1 + 1 Application.ScreenUpdating = True MsgBox "Finished!" End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
PVK is declared as an integer. The value you suggested is a decimal. Try
declaring PVK as a Single. cheers, Matt. "Gunnar" wrote in message ... Hi, I have declared a variable as Integer, and I am trying to put a value into it, but it will not work. Is the sentence below wrong?? When I use F8 the value of the cell is 0.3..but it will not be transferred into PVK....what is wrong? PVK = ShtMatrise.Range("BJ" & ProduktRad2).Value Does anyone have a clue on this one? Help is highly appreciated... Gunnar ------ here is the total code Sub FindPVC() Dim Produkt1 As Long Dim Produkt2 As Long Dim PasteRow As Integer Dim ProduktRad1 As Long Dim ProduktRad2 As Long Dim PVK As Integer Dim ShtFlasker As Worksheet Set ShtFlasker = Sheets("Flasker") Dim ShtMatrise As Worksheet Set ShtMatrise = Sheets("Matrise") ' Turn off screen updating to speed up macro. Application.ScreenUpdating = False ShtFlasker.Activate ProduktRad1 = 6 ProduktRad2 = 13 PasteRow = 6 Produkt1 = Range("F" & ProduktRad1).Value 'legger inn mat.# i flasker For Each c In Range("ProduktListe") ShtMatrise.Activate Produkt2 = Range("C" & ProduktRad2).Value 'legger inn mat# i matrise arket Do While Produkt1 = Produkt2 ' viss match 'ShtMatrise.Activate PVK = ShtMatrise.Range("BJ" & ProduktRad2).Value ' hente PVk verdi Selection.Copy ShtFlasker.Range("T" & PasteRow) = PVK ' overfør verdien PasteRow = PasteRow + 1 ' øk med en ProduktRad1 = ProduktRad1 + 1 Loop ProduktRad2 = ProduktRad2 + 1 Next c 'ProduktRad1 = ProduktRad1 + 1 Application.ScreenUpdating = True MsgBox "Finished!" End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Runtime Error '91' Object variable or With block variable not set | Excel Discussion (Misc queries) | |||
How to graph x-variable versus y-variable in Excel ? | New Users to Excel | |||
variable height variable width stacked bar charts | Charts and Charting in Excel | |||
Sum cells based on a row variable and seperate column variable | Excel Worksheet Functions | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions |