SAGAR VYAS

New Member
Joined
Dec 31, 2022
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Sub SV()

Dim I, J, K, L As Integer


Sheet1.Activate
I = 1 'InputBox("enter value")
J = 1 'InputBox("enter value")
K = 2 'InputBox("enter value")
L = 2 'InputBox("enter value")

Range(Cells(I, J), Cells(K, L)).Copy

End Sub

Sub SAGAR()

Dim I, J, K, L As Integer


Sheet1.Activate
I = InputBox("enter value")
J = InputBox("enter value")
K = InputBox("enter value")
L = InputBox("enter value")

Range(Cells(I, J), Cells(K, L)).Copy

End Sub

FIRST VBA CODE RUN PROPERLY BUT IN SECOND I AM GETTING A ERROR "error application or object defined error"
Any one can help me.
THANKS
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi Sagar Vyas,

try

VBA Code:
Sub SAGAR()

Dim I As Integer, J As Integer, K As Integer, L As Integer

I = Application.InputBox("enter value", Type:=1)
J = Application.InputBox("enter value", Type:=1)
K = Application.InputBox("enter value", Type:=1)
L = Application.InputBox("enter value", Type:=1)

If I > 0 And J > 0 And K > 0 And L > 0 Then
  Sheet1.Range(Cells(I, J), Cells(K, L)).Copy
End If
End Sub

or

VBA Code:
Sub SAGAR_mod()

Dim rng As Range

Sheet1.Activate
Set rng = Application.InputBox("enter range to copy", "Range to copy", Type:=8)
rng.Copy
Set rng = Nothing
End Sub

ciao,
Holger
 
Upvote 0
Solution

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top