2 New Messages
Digest #2215
Messages
Sun Apr 7, 2013 4:05 am (PDT) . Posted by:
"Mr. Kid" nmkid.family@ymail.com
Pak Mansor,
Kalau ndak salah duga,
1. Pada baris script : Set selectedRng =
Application.InputBox(Prompt:=askForCell, Title:=askTitle, Type:=8)
akan muncul error ketika user tidak menginput data range dengan benar atau
ketika dikosongkan.
Untuk hal ini, maka bisa diubah menjadi :
on error resume next
Set selectedRng = Application.InputBox(Prompt:=askForCell, Title:=askTitle,
Type:=8)
if err.number<>0 then
err.clear
on error goto 0
exit sub
endif
2. Pada baris script : Set rng = Range(selectedRng)
Jika yang dimaksud akan mengisikan data yang di-select user melalui input
box tipe range ke sebuah variabel baru, maka bentuknya :
Set rng=selectedrng
karena hasil inputbox bertipe 8 adalah object range.
3. Pada blok FOR EACH NEXT di baris yang berbunyi : For Each cell In rng
dengan adanya baris sebelumnya yang tampaknya variabel rng diisi dengan
hasil InputBox tipe 8 (input range), maka bisa diubah menjadi :
For Each cell In selectedRng
dan tidak memerlukan baris berbunyi :
Set rng = Range(selectedRng) 'yang bermasalah
atau baris seperti :
set rng=selectedRng
Kira-kira susunan script lengkap akan menjadi :
Private Sub CommandButton1_Click()
Dim rng As Range, cell As Range, selectedRng As Range
Dim askForCell As String, askTitle As String
askForCell = "Select your range"
askTitle = "Get cell"
on error resume next
Set selectedRng = Application.InputBox(Prompt:=askForCell,
Title:=askTitle, Type:=8)
if err.number<>0 then
err.clear
on error goto 0
exit sub
endif
'Set rng = Range(selectedRng)
For Each cell In selectedRng 'rng
If cell.Value >= 50 Then
cell.Font.ColorIndex = 5
Else
cell.Font.ColorIndex = 3
End If
Next cell
End Sub
Wassalamu'alaikum Wr. Wb.,
Kid.
On Sun, Apr 7, 2013 at 12:29 PM, Mansor <dbpermatasari@gmail.com > wrote:
> **
>
>
> Para Teman BeExcel,
>
> Tolong saya cari di mana error nya. File dilampirkan
>
> Terima kasih
> -Mansor
>
> Private Sub CommandButton1_Click()
>
> Dim rng As Range, cell As Range, selectedRng As Range
>
> Dim askForCell As String, askTitle As String
>
> askForCell = "Select your range"
>
> askTitle = "Get cell"
>
> Set selectedRng = Application.InputBox(Prompt:=askForCell,
> Title:=askTitle, Type:=8)
>
> Set rng = Range(selectedRng)
>
> For Each cell In rng
>
> If cell.Value >= 50 Then
>
> cell.Font.ColorIndex = 5
>
> Else
>
> cell.Font.ColorIndex = 3
>
> End If
>
> Next cell
>
> End Sub
>
>
>
Kalau ndak salah duga,
1. Pada baris script : Set selectedRng =
Application.
akan muncul error ketika user tidak menginput data range dengan benar atau
ketika dikosongkan.
Untuk hal ini, maka bisa diubah menjadi :
on error resume next
Set selectedRng = Application.
Type:=8)
if err.number<
err.clear
on error goto 0
exit sub
endif
2. Pada baris script : Set rng = Range(selectedRng)
Jika yang dimaksud akan mengisikan data yang di-select user melalui input
box tipe range ke sebuah variabel baru, maka bentuknya :
Set rng=selectedrng
karena hasil inputbox bertipe 8 adalah object range.
3. Pada blok FOR EACH NEXT di baris yang berbunyi : For Each cell In rng
dengan adanya baris sebelumnya yang tampaknya variabel rng diisi dengan
hasil InputBox tipe 8 (input range), maka bisa diubah menjadi :
For Each cell In selectedRng
dan tidak memerlukan baris berbunyi :
Set rng = Range(selectedRng) 'yang bermasalah
atau baris seperti :
set rng=selectedRng
Kira-kira susunan script lengkap akan menjadi :
Private Sub CommandButton1_
Dim rng As Range, cell As Range, selectedRng As Range
Dim askForCell As String, askTitle As String
askForCell = "Select your range"
askTitle = "Get cell"
on error resume next
Set selectedRng = Application.
Title:=askTitle, Type:=8)
if err.number<
err.clear
on error goto 0
exit sub
endif
'Set rng = Range(selectedRng)
For Each cell In selectedRng 'rng
If cell.Value >= 50 Then
cell.Font.ColorInde
Else
cell.Font.ColorInde
End If
Next cell
End Sub
Wassalamu'
Kid.
On Sun, Apr 7, 2013 at 12:29 PM, Mansor <dbpermatasari@
> **
>
>
> Para Teman BeExcel,
>
> Tolong saya cari di mana error nya. File dilampirkan
>
> Terima kasih
> -Mansor
>
> Private Sub CommandButton1_
>
> Dim rng As Range, cell As Range, selectedRng As Range
>
> Dim askForCell As String, askTitle As String
>
> askForCell = "Select your range"
>
> askTitle = "Get cell"
>
> Set selectedRng = Application.
> Title:=askTitle, Type:=8)
>
> Set rng = Range(selectedRng)
>
> For Each cell In rng
>
> If cell.Value >= 50 Then
>
> cell.Font.ColorInde
>
> Else
>
> cell.Font.ColorInde
>
> End If
>
> Next cell
>
> End Sub
>
>
>
Sun Apr 7, 2013 4:15 am (PDT) . Posted by:
"Hendrik Karnadi" hendrikkarnadi
Ini saya dapat dari ozgrid, coba tambahkan tanda "" (string).
Salam,
HKMansor <dbpermatasari@gmail.com > wrote:Para Teman BeExcel,
Tolong saya cari di mana error nya. File dilampirkan
Terima kasih
-Mansor
Private Sub CommandButton1_Click()
Dim rng As Range, cell As Range, selectedRng As Range
Dim askForCell As String, askTitle As String
askForCell = "Select your range"
askTitle = "Get cell"
Set selectedRng = Application.InputBox(Prompt:=askForCell, Title:=askTitle, Type:=8)
Set rng = Range(selectedRng)
For Each cell In rng
If cell.Value >= 50 Then
cell.Font.ColorIndex = 5
Else
cell.Font.ColorIndex = 3
End If
Next cell
End Sub
Salam,
HKMansor <dbpermatasari@
Tolong saya cari di mana error nya. File dilampirkan
Terima kasih
-Mansor
Private Sub CommandButton1_
Dim rng As Range, cell As Range, selectedRng As Range
Dim askForCell As String, askTitle As String
askForCell = "Select your range"
askTitle = "Get cell"
Set selectedRng = Application.
Set rng = Range(selectedRng)
For Each cell In rng
If cell.Value >= 50 Then
cell.Font.ColorInde
Else
cell.Font.ColorInde
End If
Next cell
End Sub
GROUP FOOTER MESSAGE
---------------------------------------------------------------------
bergabung ke milis (subscribe), kirim mail kosong ke:
belajar-excel-subscribe@yahoogroups.com
posting ke milis, kirimkan ke:
belajar-excel@yahoogroups.com
berkunjung ke web milis
http://tech.groups.yahoo.com/group/belajar-excel/messages
melihat file archive / mendownload lampiran
http://www.mail-archive.com/belajar-excel@yahoogroups.com/
atau (sejak 25-Apr-2011) bisa juga di :
http://milis-belajar-excel.1048464.n5.nabble.com/
menghubungi moderators & owners: belajar-excel-owner@yahoogroups.com
keluar dari membership milis (UnSubscribe):
kirim mail kosong ke belajar-excel-unsubscribe@yahoogroups.com
---------------------------------------------------------------------
bergabung ke milis (subscribe), kirim mail kosong ke:
belajar-excel-subscribe@yahoogroups.com
posting ke milis, kirimkan ke:
belajar-excel@yahoogroups.com
berkunjung ke web milis
http://tech.groups.yahoo.com/group/belajar-excel/messages
melihat file archive / mendownload lampiran
http://www.mail-archive.com/belajar-excel@yahoogroups.com/
atau (sejak 25-Apr-2011) bisa juga di :
http://milis-belajar-excel.1048464.n5.nabble.com/
menghubungi moderators & owners: belajar-excel-owner@yahoogroups.com
keluar dari membership milis (UnSubscribe):
kirim mail kosong ke belajar-excel-unsubscribe@yahoogroups.com
---------------------------------------------------------------------
Tidak ada komentar:
Posting Komentar