Hi, is it possible to use the for each sh method to insert row? My current code is this and get object defined errors. Pls help, Thanks in adv.
Please Login or Register to view this content.
Hi, is it possible to use the for each sh method to insert row? My current code is this and get object defined errors. Pls help, Thanks in adv.
Please Login or Register to view this content.
Last edited by rename; 12-06-2012 at 04:28 AM.
That code should work as long as RowNum has a valid value.
If posting code please use code tags, see here.
Doesn't seem to work sh.range cannot work
How does it not work?
Errors? Incorrect results? Nothing happens?
What have you declared sh as? What is the value for RowNum?
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
I got some object define errors. The value in RowNum is UserInput. It still wont work after i changed it into n integer. I declare sh as worksheets.
I can get this to work. The problem is with the sh.rows. Anyone know how to replace sh.Range("A2") = "Test" into inserting rows for user input? Thanks.Please Login or Register to view this content.
ChangetoPlease Login or Register to view this content.
Please Login or Register to view this content.
Regarding this - change it toAnyone know how to replace sh.Range("A2") = "Test" into inserting rows for user input?Please Login or Register to view this content.
How are you getting input from the user?
Thanks but thats not what i want. Sorry i think i did not rephrase my question properly. i do not want to have the "test" value in the row number. I want to insert a row in the row number based on the user input eg if user input is 8 then then all those sheets that is not blank in A1 will insert a new row in row 8.
Can you post the code that gets the user input?
Are you checking that the user actually enter something and that it's valid?
This is the code
Error : Select method of range class failed.Please Login or Register to view this content.
What is RowNum declared as?
Hi -
You have a hidden sheets which causing that error.
Regards,
Event
RowNum Is Integer. What do you mean by hidden sheets which cause error? I have no hidden sheets.
ChangetoPlease Login or Register to view this content.
Please Login or Register to view this content.
You don't need to select the row and try this
Please Login or Register to view this content.
aelgadi
> Click Star if I helped. Thanks
wow thanks. I got it!!
Last edited by rename; 12-06-2012 at 02:51 AM.
Try this code - It worked at my end -
Put it in a standard module.Please Login or Register to view this content.
Thanks you guys very much. Both of the coding works perfect.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks