Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Need some VBA code :)
New Posts  All Forums:Forum Nav:

Need some VBA code :) - Page 3

post #21 of 34
Thread Starter 
I just ran the code Mr. Duckie and it said error "loop without DO"
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
post #22 of 34
Thread Starter 
I tried adding the word "Do" like everywhere and it still gave me the error haha.
I am a noob I'm afraid, any insight on what this means?
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
post #23 of 34
Opps... Change "Loop" to "Next". It is "Do While.. Loop" or "For.. Next".

Code:
    ActiveSheet.Paste
    Application.CutCopyMode = False
    i = i + 1
Loop
    
End Sub

Edited by DuckieHo - 12/17/08 at 8:01am
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
post #24 of 34
Thread Starter 
Quote:
Originally Posted by DuckieHo View Post
Opps... Change "Loop" to "Next". It is "Do While.. Loop" or "For.. Next".

Code:
    ActiveSheet.Paste
    Application.CutCopyMode = False
    i = i + 1
Loop
    
End Sub
Thanks! Another problem however haha
It copies it in seemingly random places for each sheet and only copies it into one cell. The data from (vehicle list sheet) vehicle ID is A3 down to A212 and from Vehicle Description is from B3 down to B212. And on the master template it must paste these values from B9 to B34 and C9 to C34 respectively.

Sorry im being such a hassle :/
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
post #25 of 34
Quote:
Originally Posted by SilentStryke View Post
Thanks! Another problem however haha
It copies it in seemingly random places for each sheet and only copies it into one cell. The data from (vehicle list sheet) vehicle ID is A3 down to A212 and from Vehicle Description is from B3 down to B212. And on the master template it must paste these values from B9 to B34 and C9 to C34 respectively.

Sorry im being such a hassle :/
It's code so it's not random.


Try these edits:
Code:
    vehID = Cells(i, 1)
    vehNm = Cells(i, 2)
Code:
    Cells(9, 2) = vehID
    Cells(9, 3) = vehNm
    Range(Cells(9, 2), Cells(9, 3)).Select

VBA isn't that hard.... What I am doing is pretty straight foward and the comments should give you enough hints.
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
post #26 of 34
Thread Starter 
Beautiful! I read the comments, which I really do appreciate but when i type something in the program explodes with errors haha.
One last thing and itll be perfect!
The master template combines the 2 cells into 1 somehow (no idea how) and that counts as one larger cell to accomdate the longer vehicle names.
And also it only copies it down 1 cell, I tried to modify the
ActiveSheet.Paste
Application.CutCopyMode = False
i = i + 12

But i get errors. Am i changing the wrong thing?
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
post #27 of 34
Thread Starter 
Would you mind if I just attached both files?
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
post #28 of 34
Quote:
Originally Posted by SilentStryke View Post
Beautiful! I read the comments, which I really do appreciate but when i type something in the program explodes with errors haha.
One last thing and itll be perfect!
The master template combines the 2 cells into 1 somehow (no idea how) and that counts as one larger cell to accomdate the longer vehicle names.
And also it only copies it down 1 cell, I tried to modify the
ActiveSheet.Paste
Application.CutCopyMode = False
i = i + 12

But i get errors. Am i changing the wrong thing?
Try
Code:
i = i + 2
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
post #29 of 34
Thread Starter 
Attached the files if you wouldnt mind trying yourself.
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
Little Smoky
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel E8400 Wolfdale 3.0GHz Gigabyte GA-EP45-UD3P EVGA GTX 260 896MB G.Skill 4GB DDR2 1000 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar 500gb Samsung DVD +/- RW Windows 7 64 Bit 22 Acer LCD 5ms Response 
KeyboardPowerCaseMouse
Logitech Corsair 750WATT Coolermaster Sniper Logitech 
  hide details  
Reply
post #30 of 34
Now pay me!


Code:
Sub Copier()
Dim vehID As String
Dim vehNm As String
Dim numVeh As Integer
Dim i As Integer
Dim j As Integer

' Get the number of vehicles to create tabs
    Sheets("Vehicle List").Select
    Range("C65536").Select
    numVeh = Selection.End(xlUp).Row - 3

' Loop for each vehicle
For i = 3 To numVeh + 3
    ' Get vehicle ID and Name
    Sheets("Vehicle List").Select
    vehID = Cells(i, 3)
    vehNm = Cells(i, 4)
    
    ' Copy and rename template to vehID
    Sheets("Master Template").Copy Before:=Sheets(1)
    Sheets("Master Template (2)").Select
    Sheets("Master Template (2)").Name = vehID

    ' Insert vehicle ID/name and then copy down
    For j = 9 To 33
        Cells(j, 2) = vehID
        Cells(j, 3) = vehNm
        j = j + 1
    Next
Next

End Sub

Edited by DuckieHo - 12/17/08 at 11:28am
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Need some VBA code :)